Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create standard Client and Album interfaces #9

Open
ncitron opened this issue Sep 12, 2020 · 0 comments
Open

Create standard Client and Album interfaces #9

ncitron opened this issue Sep 12, 2020 · 0 comments
Assignees

Comments

@ncitron
Copy link

ncitron commented Sep 12, 2020

Current Solution

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants