There is a lot of duplicated codes. (like getting exact level, display level, etc..)
This different code can potentially cause strange bugs for any page. (wrong usage of calculating stuffs)
And there is a source code to calculate difficulty for song Link in multiple places. It can also cause bugs.
So I have a plan to put all things in one place using Hexagonal Architecture.
Here's the step to refactor it.
Move some external api calls into API class. it would be located in common/infra folder.
Create SongDatabaseFactory and move insertOrUpdateSong, updateSong, deleteSong, validate method into it.
Create 3 public methods to simply get difficulty data.
new class SongDetails
it has readonly property, property: SongProperty | undefined
it has getLevel method, which returns exact difficulty number and display value at once.
There is a lot of duplicated codes. (like getting exact level, display level, etc..)
This different code can potentially cause strange bugs for any page. (wrong usage of calculating stuffs)
And there is a source code to calculate difficulty for song
Link
in multiple places. It can also cause bugs.So I have a plan to put all things in one place using Hexagonal Architecture. Here's the step to refactor it.
common/infra
folder.insertOrUpdateSong
,updateSong
,deleteSong
,validate
method into it.SongDetails
property: SongProperty | undefined
getLevel
method, which returns exact difficulty number and display value at once.I will push it as separated PR, because this can be a large refactoring.