Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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