Home > Patterns and Practices > Facade Pattern

Facade Pattern

Façade Pattern

Problem:

You need to simplify an otherwise comlex interface. For example a Client opens a “Database” object, get the “Model” object and queries it for the “Element” object.

The problem with this approach is client has dependency on Database, Model and the element objects. Also if you need to add one more client this needs to be repeated (open database, get model and query Element). So what is the solution?

 

Solution:

Make a simple interface called DatabaseFacade which opens the database gets the model and queries for the element and returns it to the client. In this scenario the client is just coupled with DatabaseFacde and Element objects and no the others. Usual you see Remote Façades as you would like the Remote interface as simple as possible.

 

Check here for a better example:

http://www.martinfowler.com/eaaCatalog/remoteFacade.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: