Created
February 18, 2014 15:53
-
-
Save LuisRBarreras/9073619 to your computer and use it in GitHub Desktop.
Example Dependency Inversion Principle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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