Welcome to my blog

I blog my interests and opinions here.

Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Thursday, November 18, 2010

Mediator pattern and coupling

The mediator pattern in a behavioral pattern unlike structural patterns such as facade and adaptor.

Mediator Pattern: In layman's terms a mediator is a person who acts as a point of reference between parties. In the same sense a mediator class is one that acts as a point of reference between two classes that depend on each other. In an environment where the requirements and the system design is continuously changing such a design pattern is used.

Introducing a mediator reduces the coupling between the classes thus making maintenance of the application relative easy.

Wednesday, November 17, 2010

Difference between Facade pattern and the adaptor pattern

Both the facade and adaptor patterns are structural patterns.

Facade Pattern: In layman's terms the facade pattern could be thought of as the front end of a building. The facade pattern provides a single interface for various calling clients. It organizes the code in a better more readable fashion, hides the inner working of the system and reduces the network traffic.

Adaptor Pattern: The adaptor pattern could be thought of as a power adaptor used in UK for a device that is meant to work in USA voltage. In the adaptor pattern the calling client uses the adaptor as a single interface to perform the same operation. The adaptor in turn decides which operation should be called based on the environment.

The conclusion is that the facade pattern provides a single interface for multiple operations and the adaptor pattern provides a single interface for the same operation.