Search code examples
design-patternsfacade

Facade goes inside in each package or must have a package only for facades?


Where the Facade classes must go? Supposing I have three packages, Facade A goes inside Package A, Facade B goes inside Package B and Facade C goes inside Package C or I need a separate package only for Facades?

What is more recommended?

I'm using the first solution, but I think is not right. Some classes are using a facade that allocates some objects that the class not uses.


Solution

  • It really depends on how your packages are organized.

    Suppose you have payment, hr and contacts packages, then it would make sense to have a façade for each of them.

    If you split your package in a less domain driven way, like for example services, dao and web then making a facade only for the service layer would make sense.