Skip to content

Instantly share code, notes, and snippets.

@luissilvazup
Created June 17, 2020 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luissilvazup/44036ce61e6a2c38f3d9b810d8a90b81 to your computer and use it in GitHub Desktop.
Save luissilvazup/44036ce61e6a2c38f3d9b810d8a90b81 to your computer and use it in GitHub Desktop.
DIP Solution Part 2
public class D_DependencyInversionSolution {
private static class AuthenticateLogin {
private final Authentication authentication;
private AuthenticateLogin(Authentication authentication) {
this.authentication = authentication;
}
public boolean login(User user){
return authentication.login(user);
}
}
public static void main(String[] args) {
User user = new User("email@mail.com", "123");
AuthenticateLogin authenticateLogin = new AuthenticateLogin(new AuthenticationLinkedin());
authenticateLogin.login(user);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment