java
java copied to clipboard
Add concept: `optionals`
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.
After adding the concept, it should probably be added as a prerequisite to the following practice exercises:
- Error Handling
- Word Search
I would like to try on this one!
Great, looking forward to it! I'll assign you.
@manumafe98 just checking; are you still working on this? Or did it perhaps fall off your radar while tackling the other issues? 😉
@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
@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.
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()
.