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 maps concept #2914

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add maps concept #2914

wants to merge 4 commits into from

Conversation

kahgoh
Copy link
Member

@kahgoh kahgoh commented Feb 17, 2025

Add maps concept

Resolves #2583


Reviewer Resources:

Track Policies

It is similar to dictionaries in other programming languages.
The [Map][map-javadoc] interface defines operations on a map.

Java has a number Map implementations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: number of

Copy link
Contributor

@josealonso josealonso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kahgoh, a very complete explanation and well-written exercise!

@kahgoh kahgoh marked this pull request as ready for review February 17, 2025 04:54
Copy link
Contributor

@manumafe98 manumafe98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! @kahgoh this one will be very useful to the students of exercism!

@manumafe98 manumafe98 added the x:size/large Large amount of work label Feb 17, 2025

public class DialingCodes {

private final Map<Integer, String> countryByDialingCode = new HashMap<>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manumafe98 I'm wondering whether I should remove this? I had originally put this here to make it clearer where the Map is defined, but then again classes is set as a prerequisite (so students could probably work out to define a field). I would add a hint if removed.

Another might option is to replace this with something like:

// TODO: Make a Map instance
private final Map<Integer, String> countryByDialingCode = null;

Do you have any thoughts on what we should do here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I will remove it too, I think if they reach this part of the track they should know were to define it.
And also it give us leverage to work on an extra actionable if for example a student does something like this

    public Map<Integer, String> getCodes() {
        Map<Integer, String> countryByDialingCode = new HashMap<>();
        return Map.copyOf(countryByDialingCode);
    }

To check that they initialize the map as a field and not inside the methods

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I'll remove it from the stub and update the hints.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @manumafe98. Students have already defined a list in a previous learning exercise.

Copy link
Contributor

@josealonso josealonso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very easy to understand explanation on the hash value. Good work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:size/large Large amount of work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add concept: maps
3 participants