Consider that the Facade has inside it lots of sub-components but it done not pass messages from one sub-component to the other but also has some business logic in it. Is it still Facade pattern?
-
1It would be beneficial if you add some code or pseudo code to clarify what you are talking about. – enderland Oct 25 '16 at 16:17
-
1@enderland Learn to think abstract. Programming is not only about the code. – Narek Oct 26 '16 at 05:44
1 Answers
I'm sure there's going to be a little debate here, but if we assume a Facade is a simplified interface into a larger body of code, then it can contain some business logic.
For example, say I have three calls I need to make, Method1, Method2, and Method3. They are each in disparate parts of the codebase, and there is not a mechanism for them to communicate with each other, but they need to act on a common object. At a minimum, I would use my Facade to pass the object into each method. What happens if I need to only pass them conditionally? Then I just add it into the facade class.
I would say that if you do the bulk of your business logic in the facade class, then you are probably not using the design pattern correctly. At its heart it is supposed to wrap other things, not do all the work itself, but some limited business logic should be fine.
Compare this design pattern to the Adapter pattern, which more literally translates from one system to what is expected by another, with zero business logic not involved in the translation.

- 550
- 5
- 13
-
Do you think the Facade with lots of business logic in it is a Mediator? – Narek Oct 26 '16 at 05:45
-
It could be. Design Patterns are general principles, and not necessarily set in stone (typically you only really worry about following them precisely if you're in school and are getting a grade for it) – Marshall Tigerus Oct 26 '16 at 13:33