Search code examples
design-patternsunit-of-workentity-framework-ctp5

It is a good idea to implement a facade service between the controllers and services?


In the scenario where i am using an unit of work into each service class methods in order to do operations and application logic. It is a good idea to implement a facade service between the controllers and services ? The idea was to be able to use many services in one transaction without using more than one unit of work.

Thanks.


Solution

  • I think its a good idea if

    1) the services you all from the controllers themselves invoke other services, and it is getting to be unmanageable.
    2) you are struggling with a situation where you need to call two services at a high level but are having trouble making it work design-wise

    As kohlehydrat mentions, they are very useful with SOAs, but I disagree in that a Facade is a design pattern -- it isn't exclusive to anyone application style. If you use a facade, you end up with one, well organized high level service for your application (if you do it right).