nicolasbrailo / PianOli

Android baby game
GNU General Public License v3.0
59 stars 18 forks source link

Melody refactor #69

Closed juleskers closed 12 months ago

juleskers commented 1 year ago

I'm practicing my refactoring-fu, and have been wanting to try out JUnit5 for ages.
The result is this branch :smile:

Please let me know what you think!

It:

pserwylo commented 12 months ago

These are great, thanks. I personally prefer the hashmap to the large case statement (am not sure that the space is something to worry about given even much older and low-spec devices), but am not fussy. Super happy with everything else, especially the test cases. I'll go and add a GitHub Action file to run those tests and do a test build after merging.

Regarding the Melodies in single files - I did contemplate moving them into XML resource definitions, perhaps Android "asset" files, which would allow us to scan them as easily as scanning a directory. The only thing that stopped me (other than time) was the internationalisation of song names. Right now, we are almost forced to provide a strings.xml entry for each song title. Whereas if it is in XML, then we'd have to do extra work to make sure that the strings.xml contains an entry for each corresponding file, and the compiler wouldn't check it for us. I think your solution of separate classes for now is a good middleground. We don't want to have 10,000 songs to choose from anyway!

juleskers commented 12 months ago

Glad you like it, @pserwylo . I admit I was a bit nervous so thoroughly taking apart your brainchild :sweat_smile: