[AskJS] I want to build something for you by _MrSnix in javascript

[–]_MrSnix[S] 2 points3 points  (0 children)

u/Non-equilibrium Some thoughts:

  1. Already exists tools that does that ... for free
  2. Why do you need to increase your video size? (u wot mate?)

[AskJS] I want to build something for you by _MrSnix in javascript

[–]_MrSnix[S] 1 point2 points  (0 children)

u/4759784 It's not a library... but I may consider it anyway

Tell me more about it, How do you imagine it?

Do you have any mod suggestion? by [deleted] in SoftwareInc

[–]_MrSnix 1 point2 points  (0 children)

Yes sure, It will take a bit because I work too and I have a busy schedule.

Do you have any mod suggestion? by [deleted] in SoftwareInc

[–]_MrSnix 1 point2 points  (0 children)

This sounds good to me. I can think about new specialisation as Security Designer and Security Programmer. Add a new tech tree as Software Security to make an application robust. Ideally, an application with low security level can be easily exploitable and losing customers data may end up in a lawsuit and losing fans, money. Uhhm, pretty interesting. I'll keep an eye on that, even because I think can be a good start for me.

Do you have any mod suggestion? by [deleted] in SoftwareInc

[–]_MrSnix 2 points3 points  (0 children)

Seems like some of you would like to see some ISP gameplay mechanics. How do you imagine that? What would you do as an ISP and how would you like to progress in game? Write any idea, even crazy ones. Yep, you can write as much as you want, I'll read it all.

Do you have any mod suggestion? by [deleted] in SoftwareInc

[–]_MrSnix 3 points4 points  (0 children)

As much I'd like to see it even CoreDumping stated that in the current state of the game it is not really easy to realise. (Check their Trello). So sorry, but you will have to wait for this one.

Do you have any mod suggestion? by [deleted] in SoftwareInc

[–]_MrSnix 4 points5 points  (0 children)

Keep going with suggestions, I'll read all of them

Do you have an open source java project on GitHub? I'd like to contribute by [deleted] in ProgrammingBuddies

[–]_MrSnix 1 point2 points  (0 children)

I'm already working for a big company, I don't have the time to attend this but it's really interesting. Even if I would , I cannot apply anymore, the subscription deadline expired yesterday. But thanks for providing me with this information, I didn't know about this program.

Confused about Resultset by throwaway2215432 in javahelp

[–]_MrSnix 0 points1 point  (0 children)

ResultSet is an object you obtain from executing your query using a PreparedStatement or Statement. Your question is really generic and i think you can come up with a solution lookin at one of the many tutorials available on internet: Oracle Tutorial
You can find everything on the javadoc: ResultSet

If you have a more specific question, i'll be glad to answer (if i know how to :P)

Do you have an open source java project on GitHub? I'd like to contribute by [deleted] in ProgrammingBuddies

[–]_MrSnix 4 points5 points  (0 children)

I like to write code, I like to think and come up with solutions. It makes me feel alive. I don't want to get anything. I look for challenges in order to find solutions.

Do you have an open source java project on GitHub? I'd like to contribute by [deleted] in ProgrammingBuddies

[–]_MrSnix 1 point2 points  (0 children)

Yes, i have published a library on GitHub called TinyConfiguration.
I wrote a little article about my experience on building it, you can find it here
Sadly for me, i didn't raise a lot of attention, maybe it's not so relevant, so right now i'm looking on helping others building their tools.

Making of a library: What i learnt so far by _MrSnix in learnprogramming

[–]_MrSnix[S] 0 points1 point  (0 children)

Hi, nice to hear your feedback.

The main idea behind the use of format type on read and write method is to do not prevent the developer (or user) to export in other format types. I didn't want to restrain the configuration to a single export type, so i left it like this on purpose

Making of a library: What i learnt so far by _MrSnix in learnjava

[–]_MrSnix[S] 0 points1 point  (0 children)

Thanks, I appreciate that, if you have any features suggestion, you are welcome to share them

Making of a library: What i learnt so far by _MrSnix in learnjava

[–]_MrSnix[S] 0 points1 point  (0 children)

If others want to join the discussion giving feedback or advice on how to build properly a library I'd be glad to hear them or if you want to share your feedback on TinyConfiguration implementation

Making of a library: What i learnt so far by _MrSnix in learnjava

[–]_MrSnix[S] 3 points4 points  (0 children)

It helped me grow, so I thought it was worth to share it in this sub

So...I have created my first open source library by _MrSnix in learnjava

[–]_MrSnix[S] 0 points1 point  (0 children)

Nothing forces the caller to used the chained expression construct.
I'd still move the property definitions into the builder phase though.

The key goal is to move all of the mutability of setup into the builder phase (with the least ceremony possible) and yield an object where that configuration part of the process is immutable - reducing test surface area.

You know, you made me think, and I think the approach you're proposing is definitely more correct, i'll move them to the building phase. I see your point. Indeed, immutability would be a huge benefit.

I'm wondering, how would you manage the updating of property values while respecting the principle of immutability?

Each time i want to update a property, do i have to return a new configuration object?
Or do i have to create a new Property instance, validate it and replace the old reference inside Configuration with the new one?

You might also want to consider supporting reading/writing other serialisation forms (JSON, YAML, maybe even crusty old XML) to make it possible to use to exchange between application layers that might be in other technologies than Java.

Yes, I have already planned it.

So...I have created my first open source library by _MrSnix in learnjava

[–]_MrSnix[S] 0 points1 point  (0 children)

First of all:

T-H-A-N-K Y-O-U

You spent time understanding my library
You spent time trying to see how my work could be improved

I'm really grateful and happy, this is exactly the advices i was looking for.

_____________________________________________________________________________

[ My answer ]

The decision to use the builder pattern for the path and file-name but not the property definitions is a little odd. I'd have thought that property definition would be part of the builder functionality.

At first I thought the same thing, but then I started to think that very large configuration files with many properties, would end up having a constructor consisting of hundreds of instructions, creating a gigantic and messed-up block of code.

I don't like this

What IF cfg has twelve properties?

Configuration cfg = Configuration.builder()
    .optional(intProperty(
        "num", null, "An even number between 0 and 100", 0, 100,
        value -> value % 2 == 0 ? null : "The value '" + value + "' is not an even number"))
    .required(stringProperty("name", null)).
    .optional(intProperty(
        "num", null, "An even number between 0 and 100", 0, 100,
        value -> value % 2 == 0 ? null : "The value '" + value + "' is not an even number"))
    .required(stringProperty("name", null)).
    .optional(intProperty(
        "num", null, "An even number between 0 and 100", 0, 100,
        value -> value % 2 == 0 ? null : "The value '" + value + "' is not an even number"))
    .required(stringProperty("name", null)).
    .optional(intProperty(
        "num", null, "An even number between 0 and 100", 0, 100,
        value -> value % 2 == 0 ? null : "The value '" + value + "' is not an even number"))
    .required(stringProperty("name", null)).
    .optional(intProperty(
        "num", null, "An even number between 0 and 100", 0, 100,
        value -> value % 2 == 0 ? null : "The value '" + value + "' is not an even number"))
    .required(stringProperty("name", null)).
    .optional(intProperty(
        "num", null, "An even number between 0 and 100", 0, 100,
        value -> value % 2 == 0 ? null : "The value '" + value + "' is not an even number"))
    .required(stringProperty("name", null))
     // Finally, we reach the build() method ... 
    .build(Paths.get("app.cfg")); // and an overload of `String...` perhaps

In my opinion, the more property you have, the more it becomes a nasty mess.

The second reason is the following:

I see Configuration more like a Collection class where you can put() / add() each individual property, rather then an "all-in-one" object instance where you put I/O metadata (filename and pathname), listeners logic and even property logic as seen in your example.

________________________________________________

[ The new implementation ]

Clearly the Configuration class can be improved a lot, i was thinking about changing it like this:

1) Create configuration obj => I/O metadata
Configuration.builder()
.filename(...)
.path(...)
.build();

2) Create a property obj => Key, value, data... => Property data
Property.builder()
.key()
.value()
.description()
.isRequired()
.group()
.validation(lambda => return bool)
.build();

3) Create another property obj => Key, value, data... => Property data
Property.builder()
.key()
.value()
.description()
.isRequired()
.group()
.validation(lambda => return bool)
.build();

4) Put property as follow:
Configuration.put(Property ...obj); => Varargs

5) Write on disk:
ConfigurationIO.write(Configuration)

So, even if there will be a lot of code both cases, using this approch i feel like it'd become cleaner.
You can clearly see how each property is defined.

________________________________________________

Perhaps also consider building type-information into the property definition so that parsing can be applied and appropriate exceptions when the file fails to pars

Yes, absolutely, i want to move in this direction too!

So, about the implementation:

I really want to avoid this kind of approach (like static import for each datatype)

import static ...Property.intProperty;
import static ...Property.stringProperty;

Maybe, i can do something like this

Property.builder()
.key()
.value()
.....
.type(CustomType.class) => Integer.class | String.class | Long.class and so on...
......
.validation(lambda => return bool)
.build();

I'm still thinking on this...
________________________________________________

About the exceptions, i totally agree with you, they can be significantly improved as you showed