exercism / java

Exercism exercises in Java.
https://exercism.org/tracks/java
MIT License
696 stars 673 forks source link

Add concept: `optionals` #2555

Open sanderploegsma opened 11 months ago

sanderploegsma commented 11 months ago

The goal of this issue is to add a new concept to the Java track that introduces optionals. The corresponding concept exercise can probably be based on the "Role Playing Game" exercise from the Rust track or the Elm track.

Instructions on how to contribute to the Java track and how to implement concept exercises can be found in the contributing guide.

As always, leave a comment here if you want to work on this exercise, and we'll assign it to you. In case you have any further questions, feel free to ask here.

sanderploegsma commented 11 months ago

After adding the concept, it should probably be added as a prerequisite to the following practice exercises:

manumafe98 commented 10 months ago

I would like to try on this one!

sanderploegsma commented 10 months ago

Great, looking forward to it! I'll assign you.

sanderploegsma commented 9 months ago

@manumafe98 just checking; are you still working on this? Or did it perhaps fall off your radar while tackling the other issues? 😉

manumafe98 commented 9 months ago

@sanderploegsma This is still under my radar! just I was trying to get more knowledge on how to create exercises to make a better job

manumafe98 commented 8 months ago

@sanderploegsma I was thinking on how to tackle this concept, and checking the rust example that you passed in the description, they introduce in the same exercise the nullability concept. We already have a our own concept exercise for nullability and my idea was maybe to introduce Optionals in that same exercise as we have done for example with the exercise that introduces List and Generics, I would like to know your opinion on this idea.

sanderploegsma commented 8 months ago

I'm not sure that is a good idea to be honest. null and java.util.Optional are two very different concepts that I think deserve to be highlighted in their own respective exercises. I don't want to teach students that one is better than the other, as it's perfectly fine in Java to never use Optional.

checking the rust example that you passed in the description, they introduce in the same exercise the nullability concept

Not really though, the Rust track doesn't have a concept nullability, it only provides the option concept. That's because unlike Java, Rust doesn't have null. It has None, but that is just an Option<T> with no value, which would translate to Java's Optional<T>.empty().