Skip to content

Instantly share code, notes, and snippets.

View D_DependencyInversionSolution.java
public class D_DependencyInversionSolution {
private static class AuthenticateLogin {
private final Authentication authentication;
private AuthenticateLogin(Authentication authentication) {
this.authentication = authentication;
}
public boolean login(User user){
View D_DependencyInversionSolution.java
public class D_DependencyInversionSolution {
@AllArgsConstructor
private static class AuthenticateLogin {
private final Authentication authentication;
public boolean login(User user){
return authentication.login(user);
}
}
View D_DependencyInversionProblem.java
public class D_DependencyInversionProblem {
@AllArgsConstructor
private static class AuthenticateLogin {
public boolean login(User user){
AuthenticationLinkedin authentication = new AuthenticationLinkedin();
return authentication.login(user);
}
}
View I_InterfaceSegregationSolution.java
public class I_InterfaceSegregationSolution {
public interface Car {
void openDoor();
}
public interface ElectricCar {
void charge();
}
View I_InterfaceSegregationProblem.java
public class I_InterfaceSegregationProblem {
public interface Car {
void charge();
void openDoor();
}
public static class Fiesta implements Car {
@Override
public void charge() {
View L_LiskovSubstituitionProblem.java
public class L_LiskovSubstituitionProblem {
@Getter
@Setter
private static class BasicAccount {
protected double balance = 0;
public void yield() {
this.balance += (this.balance * 0.15);
}
View O_OpenClosedSolution.java
public class O_OpenClosedSolution {
@AllArgsConstructor
private static class AuthenticateLogin {
private Authentication authentication;
public boolean login(User user){
return authentication.login(user);
}
}
View O_OpenClosedSolution.java
public class O_OpenClosedSolution {
private interface Authentication {
boolean login(User user);
}
private static class AuthenticationLinkedin implements Authentication {
@Override
public boolean login(User user) {
//autêntica o login com o Oauth Linkedin.
View O_OpenClosedProblem.java
public class O_OpenClosedProblem {
private static class AuthenticateLogin{
public boolean login(User user, String provider){
ConnectionDAO connectionDAO = new ConnectionDAO("root", "");
Connection connection = connectionDAO.createConnection();
if(provider.equalsIgnoreCase("Linkedin")){
//autêntica o login com o Oauth Linkedin
}
View S_SingleResponsabilitySolution.java
public class S_SingleResponsabilitySolution {
private static class AuthenticateLogin {
public boolean login(User user) {
ConnectionDAO connectionDAO = new ConnectionDAO("root", "");
Connection connection = connectionDAO.createConnection();
//realiza o login do usuário no sistema
}
}
}