Skip to content

Instantly share code, notes, and snippets.

@LuisRBarreras
Created February 18, 2014 15:53
Show Gist options
  • Save LuisRBarreras/9073619 to your computer and use it in GitHub Desktop.
Save LuisRBarreras/9073619 to your computer and use it in GitHub Desktop.
Example Dependency Inversion Principle
interface Mailer {
public void send();
}
class Gmail implements Mailer {
public void send() {
//....send mail
}
}
class Hotmail implements Mailer {
public void send(){
//..send mail
}
}
class Contact {
Mailer mail;
public void setMailer(Mailer m) {
mail = m;
}
public void send() {
mail.send();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment