Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design pattern "Facade"

I'm working on the issue of design patterns. In this case I want to implement design pattern 'Facade'

I know that 'Cocoa Touch' offers us complete solutions for applying design patterns in our projects (for example NSNotificationCenter - implements observer design pattern)

My questions is next: - do we have ability to using design pattern 'Facade' as well as in the case of the observer design pattern.

Now I implement 'Facade' like this:

For example i have some classes which implements some calculations. The 'Facade' class combine all classes which I needed to calculations.

For example i have classes A, B, C and Facade (which contain A, B and C classes).

When I want to calculate something I just create my 'Facade' and pass some argument for calculation. In this case I don't know about classes A, B, C and this Facade object provides me one access point only.

This design pattern encapsulates objects and simplifies the application.

Is it correct implementation?

like image 643
Matrosov Oleksandr Avatar asked Feb 20 '12 14:02

Matrosov Oleksandr


3 Answers

Another a good example for implementing facade pattern - pizza call service. For example, pizza service (subsystem) is very large and it consists of three departments (interfaces) : order department, discount department, delivery department. Each departments has own logic and interfaces. You can simply implement facade pattern on it. Here this example in more details.

like image 165
Developex Avatar answered Sep 22 '22 08:09

Developex


A Facade is defined as unified interface to a bunch of interfaces - sort of higher level interface to reduce the complexity. Instead of dealing with several classes and knowing the API's of each its reduced to the facade. Your explanation looks OK to me.

like image 38
hburde Avatar answered Sep 24 '22 08:09

hburde


It is correct explanation (i don't see implementation). Nice association to Facade pattern in real life is remote control - you can run TV functions, DVD and so on.

like image 45
mishadoff Avatar answered Sep 20 '22 08:09

mishadoff