Skip to content

Instantly share code, notes, and snippets.

@raulmoyareyes
Last active July 29, 2018 16:58
Show Gist options
  • Save raulmoyareyes/44e62f61f3677cad44ca2ffdbcb45985 to your computer and use it in GitHub Desktop.
Save raulmoyareyes/44e62f61f3677cad44ca2ffdbcb45985 to your computer and use it in GitHub Desktop.
Dependency Inversion Principle
class Ingredient {
// implementation
}
class Milk extends Ingredient {
// implementation
}
class Beverage {
constructor(ingredient) {
this.ingredient = ingredient
}
cost() {
// calculate the cost
}
}
class Coffee extends Beverage {
cost() {
// calculate the cost
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment