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

Refactor getRandomHydrateBreakMessageForPersonality method #294

Closed
jmakhack opened this issue Oct 6, 2022 · 4 comments · Fixed by #378
Closed

Refactor getRandomHydrateBreakMessageForPersonality method #294

jmakhack opened this issue Oct 6, 2022 · 4 comments · Fixed by #378
Assignees
Labels
best practices Improve the health of the codebase good first issue Good for newcomers hacktoberfest This issue qualifies for the hacktoberfest event help wanted Extra attention is needed java Pull requests that update Java code up for grabs Any issue that is up for grabs
Milestone

Comments

@jmakhack
Copy link
Owner

jmakhack commented Oct 6, 2022

Task Context

Right now, the getRandomHydrateBreakMessageForPersonality method relies on a switch statement that needs to be updated with every newly added personality type. Also, every case in the switch statement essentially just calls the same method with a different parameter (except for RANDOM). This is not ideal as the code is unnecessarily repetitive.

Codacy also reports this as an issue, specifically a Cyclomatic Complexity issue. See:
https://app.codacy.com/gh/jmakhack/hydrate-reminder/issues?&filters=W3siaWQiOiJMYW5ndWFnZSIsInZhbHVlcyI6W119LHsiaWQiOiJDYXRlZ29yeSIsInZhbHVlcyI6WyJFcnJvclByb25lIl19LHsiaWQiOiJMZXZlbCIsInZhbHVlcyI6W119LHsiaWQiOiJQYXR0ZXJuIiwidmFsdWVzIjpbIjU0MjgiXX0seyJpZCI6IkF1dGhvciIsInZhbHVlcyI6W119XQ==

Acceptance Criteria / Goals

The goal of this task is to refactor the getRandomHydrateBreakMessageForPersonality method in HydrateBreakMessageDictionary.java.

Instead of relying on an ever growing switch statement, one possible option is to create a mapping of personality types to their respective text lists. With this approach, getRandomBreakMessage can just be just be passed the correct parameter from the map (i.e. getRandomBreakMessage(mapName[personalityType])).

This is only one possible approach though and any other approach to reduce the repetitiveness and complexity of this method is acceptable.

Additional Notes

Please refer to CONTRIBUTING.md for info on how to setup, build, run, and test this project. Feel free to ping @jmakhack in the comments below with any questions if needed. Also, join the Discord to meet and engage with other contributors!

@jmakhack jmakhack added help wanted Extra attention is needed good first issue Good for newcomers java Pull requests that update Java code best practices Improve the health of the codebase hacktoberfest This issue qualifies for the hacktoberfest event up for grabs Any issue that is up for grabs labels Oct 6, 2022
@jmakhack jmakhack added this to the Ongoing milestone Oct 6, 2022
@suryanshsangwan
Copy link

Please assign this to me

@jmakhack
Copy link
Owner Author

jmakhack commented Oct 6, 2022

Ok, it is now assigned to you @suryanshsangwan :)

@jmakhack
Copy link
Owner Author

Hi @suryanshsangwan. Just checking in, are you still working on this issue?

@hpa16
Copy link
Contributor

hpa16 commented Oct 26, 2022

Hi @jmakhack, I'd like to work on this issue if it's available to pick up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
best practices Improve the health of the codebase good first issue Good for newcomers hacktoberfest This issue qualifies for the hacktoberfest event help wanted Extra attention is needed java Pull requests that update Java code up for grabs Any issue that is up for grabs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants