Search code examples
design-patternsarchitecturefacade

Number of calls from Facade in Facade Pattern


We are having a "discussion" about what should be placed in the facade layer and how many calls the facade layer should make to the underlying layers.

In our project we have an Orchestration layer that coordinates calls to services and databases. We also have a business layer with business rules and calculations.

Our facade layer has a security check, logging and error handling.

Now the question: Should the facade have only a single call to the orchestration layer or is it Ok with multiple calls. If it is only a single call should these layers be merged into a single layer.

These are WCF services written in C#.


Solution

  • The number of calls inside of the Facade shouldn't matter as long as the call does one single operation (in the eyes of the caller) and does it completely.

    Keep in mind that a single operation to the caller may include logging, running business rules, opening a connection to the database, writing to the database, and then finally closing and cleaning up the connection.