Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concept: optionals #2555

Open
sanderploegsma opened this issue Nov 5, 2023 · 14 comments
Open

Add concept: optionals #2555

sanderploegsma opened this issue Nov 5, 2023 · 14 comments
Assignees
Labels
x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept Work on Concepts x:module/concept-exercise Work on Concept Exercises x:size/large Large amount of work x:status/claimed Someone is working on this issue x:type/content Work on content (e.g. exercises, concepts)

Comments

@sanderploegsma
Copy link
Contributor

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 sanderploegsma added x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept Work on Concepts x:module/concept-exercise Work on Concept Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/large Large amount of work labels Nov 5, 2023
@sanderploegsma
Copy link
Contributor Author

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

  • Error Handling
  • Word Search

@manumafe98
Copy link
Contributor

I would like to try on this one!

@sanderploegsma
Copy link
Contributor Author

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

@sanderploegsma sanderploegsma added the x:status/claimed Someone is working on this issue label Dec 29, 2023
@sanderploegsma
Copy link
Contributor Author

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

@manumafe98
Copy link
Contributor

@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
Copy link
Contributor

@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
Copy link
Contributor Author

sanderploegsma commented Feb 28, 2024

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().

@manumafe98 manumafe98 removed their assignment Apr 2, 2024
@manumafe98 manumafe98 removed the x:status/claimed Someone is working on this issue label Apr 2, 2024
@josealonso
Copy link
Contributor

I would like to add this concept, because I just wrote a post about Optional in my hashnode blog yesterday. Is there a concrete exercise for this concept, which has already been used in other tracks, in Scala, Kotlin or C#?
Thanks. @manumafe98 @kahgoh

@kahgoh
Copy link
Member

kahgoh commented Jan 7, 2025

I'm not quite sure what the equivalents are in Scala, Kotlin or C#. If it helps, Elm uses Role Playing Game for their Maybe concept, which I think is the closest. Check out this page for a list of exercises used for concepts in different tracks.

Since this was previously assigned to @manumafe98, I'd like to double check - @manumafe98, would you be happy for @josealonso to work on this one?

@josealonso
Copy link
Contributor

I'm not quite sure what the equivalents are in Scala, Kotlin or C#. If it helps, Elm uses Role Playing Game for their Maybe concept, which I think is the closest. Check out this page for a list of exercises used for concepts in different tracks.

Since this was previously assigned to @manumafe98, I'd like to double check - @manumafe98, would you be happy for @josealonso to work on this one?

Thanks for the info @kahgoh. I should have realized that sanderploegsma provided a link to similar exercises at the top of this page.

@josealonso
Copy link
Contributor

I finally had some time to read the detailed explanation of how to create a concept exercise. But I'm not sure which existing story I should use. I don't like the Role Playing Game story indicated above, because it's about nullable fields. I just saw the C# track uses the Tim From Marketing story for a similar concept. In fact, this is part of my Java solution:

    private String finalDepartment(String department) {
        return Optional.ofNullable(department)
                .map(String::toUpperCase)
                .orElse("OWNER");
    }

As you know, Optional is mainly used as a method returned type. Do you know if there is an existing story related to this case, @kahgoh ? In summary, I already wrote a brief explanation of the Optional concept, but I need a story.

@manumafe98

Thanks :)

@kahgoh
Copy link
Member

kahgoh commented Feb 5, 2025

For concept exercises, we can adjust the tasks to suit our needs. For example, instead of giving the students a Player object, we could give the students the bits as separate parameters (e.g. public Optional<Player> revive(String name, int health, int mana)). The story only serves as a background for the tasks in the concept exercises but the tasks don't need the same as the ones from the Elm track.

We already use Tim From Marketing for the null concept. I think we could look into doing a Tim From Marketing 2 in much the same way we have Wizards and Warriors to introduce classes and Wizards and Warriors 2 to introduce method overloading. Let me know if this is something you'd like to do.

@josealonso
Copy link
Contributor

For concept exercises, we can adjust the tasks to suit our needs. For example, instead of giving the students a Player object, we could give the students the bits as separate parameters (e.g. public Optional<Player> revive(String name, int health, int mana)). The story only serves as a background for the tasks in the concept exercises but the tasks don't need the same as the ones from the Elm track.

We already use Tim From Marketing for the null concept. I think we could look into doing a Tim From Marketing 2 in much the same way we have Wizards and Warriors to introduce classes and Wizards and Warriors 2 to introduce method overloading. Let me know if this is something you'd like to do.

Thanks for your reply !! As you point out, I'll try to use a Tim From Marketing 2 for the concept exercise.

@kahgoh kahgoh assigned kahgoh and josealonso and unassigned kahgoh Feb 9, 2025
@kahgoh kahgoh added the x:status/claimed Someone is working on this issue label Feb 9, 2025
@josealonso
Copy link
Contributor

Resolved in #2913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept Work on Concepts x:module/concept-exercise Work on Concept Exercises x:size/large Large amount of work x:status/claimed Someone is working on this issue x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

No branches or pull requests

4 participants