SongUI model / UI layer refactoring#536
Open
ztx-lyghters wants to merge 4 commits into
Open
Conversation
Refactoring of the presentation layer in terms of handling song objects. Presentation layer now operates with SongUI model objects, made specifically for UI purposes. It's a full copy of the Song model from the domain layer, with an extra isDownloaded boolean field, indicating the state of song's offline availability. This change makes SongWrapper object redundant and allows to decouple views from the domain layer version of Song model.
Mapped some stuff to SongUI
Change `toDomainSong()` naming into `toSong()`, to follow the name of the actual model they refer to. I still think `toDomainSong()` creates less confusion in the code, by avoiding `song.toSong()` situations. Maybe worth finding a different solution to this, to make the code less ambiguous. I've considered renaming the variable identifiers instead (from `song` to `songUi` and from `songs` to `songUiList` or 'songsUi'), but that's very messy and creates additional unnecessary visual clutter. So for now I would prefer leaving it like this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
SongUI- a UI layer equivalent of the domain layerSongmodel.Has one additional boolean field
isDownloadedto check the state of song's offline availability, which being checked via the dedicated methodisAvailableOffline().Implements mapper methods to convert between
SongandSongUIobjects (and lists of objects) both ways.toSongUI()mapper for a singleSongtakes a boolean as an argument to set theisDownloadedvariable, whiletoSongUI()forList<Song>takes a callback function, whereIsSongAvailableOfflineUseCasecan be passed without introducing a dependency.Makes
SongWrapperredundant (completely removes it from the code) and decouples domain'sSongmodel from UI components (outside of view models).Some naming changes are planned to make the code more readable, plus needs testing, so this is a draft for now.