Skip to content

Instantly share code, notes, and snippets.

@raulmoyareyes
Created July 29, 2018 15:30
Show Gist options
  • Save raulmoyareyes/dea4775182071804ee77c339790ffbc7 to your computer and use it in GitHub Desktop.
Save raulmoyareyes/dea4775182071804ee77c339790ffbc7 to your computer and use it in GitHub Desktop.
Single Responsability Principle
class UserAuth {
constructor(user) {
this.user = user;
}
verifyCredentials() {
// ...
}
}
class UserSettings {
constructor(user) {
this.user = user;
this.auth = new UserAuth(user);
}
changeSettings(settings) {
if (this.auth.verifyCredentials()) {
// ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment