Posts

Showing posts from December, 2014

Design pattern mediator and java implementation

Image
what is the problem I have some object and they need to communitate each other and i want a software that do it the soluzion of mediator The first, not best solution, is programming the objects (collegues) so that each object can communicate with all other objects. But in this way i have hight coupling between objects. We want avoid this. The best solution is to use an object (mediator) through each object can communicate. example class diagram> in this example i want use a simplest as possible implementation, so i use only one concrete mediator and only one concrete collegue. The target is that i want that when a collegue change its state, all other collegue must be notify of that change through the mediator. Mediator.java package mediator1; public interface Mediator { public abstract void sendMessage(String s,String n,Collegue c); public abstract void addCollegue(Collegue c); } ConcreteMediator.java package mediator1; import java.util.ArrayList; import...