Design template "Facade"

I am working on a design problem. In this case, I want to implement the Facade design template.

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

My questions are: - Do we have the opportunity to use the Facade design template, as well as in the case of the observer design template.

Now I implement the ' Facade ' as follows:

For example, I have some classes that do some calculations. The Facade class combines all the classes that I need for computing.

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

When I want to calculate something, I just create my β€œ Facade ” and pass some argument for the calculation. In this case, I do not know about classes A, B, C, and this Facade object provides me with only one access point.

This design pattern encapsulates objects and simplifies the application.

Is this the correct implementation?

+7
source share
4 answers

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

+7
source

A Facade is defined as a unified interface for a bunch of interfaces - a kind of higher-level interface to reduce complexity. Instead of dealing with several classes and knowing the API of each of them, it comes down to the facade. Your explanation looks good to me.

+7
source

This is the correct explanation (I do not see the implementation). A good association with the faΓ§ade pattern in real life is the remote control - you can run TV functions, DVDs, etc.

+4
source

The motivation for the facade template is to provide a simplified interface for frequently used cases, while also contributing to a simplified interface and interacting with the more complex aspects of the classes behind the facade, when necessary. As you described your implementation, this will undoubtedly fit the description, and there is no reason why you could not use the facade template in combination with the notification / observer template ...

+1
source

All Articles