Refactor getRandomHydrateBreakMessageForPersonality method #294
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
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 forRANDOM
). 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 inHydrateBreakMessageDictionary.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!
The text was updated successfully, but these errors were encountered: