Refactor getRandomHydrateBreakMessageForPersonality method
jmakhack opened this issue · 4 comments
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!
Please assign this to me
Ok, it is now assigned to you @suryanshsangwan :)
Hi @suryanshsangwan. Just checking in, are you still working on this issue?