You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, there is the SpotifyAlbum and SpotifyClient structs. In the future, it is likely that there will be similar structs for other APIs such as AppleMusicAlbum and AppleMusicClient.
Problem
This setup does not allow for the easy implementation of standard Album and Client structs, that all have the same behavior, but with differing backends.
Solution
For example, let's start with Album. We can create an interface Album, and define getter methods for all data that needs to be accessed from any implementation of Album. We then define SpotifyAlbum, with all of its Spotify-specific member variables and functions with private visibility. We then must define all of the publicly visible getter methods defined in the Album interface. These getters will source their data from the underlying Spotify API, but for end-users, they will not know they are using any particular version of Album.
Result
This solution allows us to use a single Album interface, without ever considering whether it is a SpotifyAlbum or AppleMusicAblum. This solution has a higher degree of abstraction, keeping implementation details away from the user of the library.
The text was updated successfully, but these errors were encountered:
Current Solution
At the moment, there is the
SpotifyAlbum
andSpotifyClient
structs. In the future, it is likely that there will be similar structs for other APIs such asAppleMusicAlbum
andAppleMusicClient
.Problem
This setup does not allow for the easy implementation of standard
Album
andClient
structs, that all have the same behavior, but with differing backends.Solution
For example, let's start with
Album
. We can create an interfaceAlbum
, and define getter methods for all data that needs to be accessed from any implementation ofAlbum
. We then defineSpotifyAlbum
, with all of its Spotify-specific member variables and functions with private visibility. We then must define all of the publicly visible getter methods defined in theAlbum
interface. These getters will source their data from the underlying Spotify API, but for end-users, they will not know they are using any particular version of Album.Result
This solution allows us to use a single
Album
interface, without ever considering whether it is aSpotifyAlbum
orAppleMusicAblum
. This solution has a higher degree of abstraction, keeping implementation details away from the user of the library.The text was updated successfully, but these errors were encountered: