Last active
November 4, 2015 13:56
-
-
Save FagnerMartinsBrack/afa08cffb16a5589db06 to your computer and use it in GitHub Desktop.
Notification OO Design Draft
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
public static void main( String[] args ) { | |
NotificationService service = new NotificationService(); | |
// Imprime todas as notificações no view | |
service.listNotifications(); | |
} |
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
public class Notification { | |
Object conteudo(); | |
Data data(); | |
Lido lido(); | |
} |
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
public class NotificationFactory { | |
Object createConteudo(); | |
Data createData(); | |
Lido createLido(); | |
} |
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
public class NotificationService { | |
List<NotificacaoValue> notificacoesDoBanco = new ArrayList<>(); | |
public List<Notification> listNotifications() { | |
List<Notification> result = new ArrayList<>(); | |
for ( NotificacaoValue notificacao : notificacoesDoBanco ) { | |
NotificacaoFactory factory = null; | |
if ( notificacao.getTipo().equals( "EMAIL" ) ) { | |
factory = new NotificacaoEmailFactory(); | |
} | |
// Constrói o resto das notificações de acordo com o tipo, | |
// cada factory vai construir as propriedades de uma forma diferente | |
result.add( new Notification( factory ) ); | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment