In my applications, I used to call Facade methods in the main application using they as Controllers because I thought they are the same thing, but now I think I was wrong.
My application use multiple Facades, each one for a kind of task. If I change to use the Controller, the right way is having only one Controller?
My question here is what is the difference between a Facade and a Controller.
Façade, by definition, is the face of a building. It is what you can see from the exterior that protects the interior. Façades are an integral part of the building shell – keeping us humans warm in the winter and cool in the summer, while also providing a barrier from outside elements and even fire in some cases.
A facade is a class that provides a simple interface to a complex subsystem which contains lots of moving parts. A facade might provide limited functionality in comparison to working with the subsystem directly.
Mediator abstracts/centralizes arbitrary communications between colleague objects. It routinely "adds value", and it is known/referenced by the colleague objects. In contrast, Facade defines a simpler interface to a subsystem, it doesn't add new functionality, and it is not known by the subsystem classes.
Implementation Variations In the domain facade approach a Service Layer is implemented as a set of thin facades over a Domain Model (116). The classes implementing the facades don't implement any business logic. Rather, the Domain Model (116) implements all of the business logic.
Normally it would be the other way around, as you tend to have fewer facades in your system then controllers. Facades are meant to be wrappers around complex functionality, their primary goal is hiding complexity of an underlying system. You can think of the Facade as a layer wrapping the complex functionality and providing simpler methods to interact with.
A controller, on the other hand, is normally tied to a very specific piece of functionality in the system. It's main goal is to mediate the interaction between a view and a model, or in some cases just a model.
It's more typical to have a facade interacting with several controllers, than vice versa.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With