Note that there are some explanatory texts on larger screens.

plurals
  1. POBusiness Layer Facade vs Mingled Business Components
    text
    copied!<p>I'm currently designing the foundation for a large application. We are going with the traditional 3 tier system using EF in the data layer, plain jane c# classes in the business layer and MVC / WCF for the ui layer. We have prototyped enough of the application to realize that this will work for us, however due to the complexity of the business requirements <strong>it will be common for some of the business components interact with one another.</strong></p> <p>Consider the following two business components:</p> <ul> <li>RetailManager - Deal with everything related to retail in the system</li> <li>CartManager - Deals with everything related to the shopping cart experience</li> </ul> <p>The two interact, for instance, during the checkout process when an item is purchased. The inventory for the purchased item needs to be reduced.</p> <p>Here is my thought process so far:</p> <ol> <li><p>Let business components reference each other and ensure cyclical references never happen (CartManager references RetailManager, but never the other way). "Checkout" would be a method on the CartManager class, and it would call a method on the RetailManager to adjust inventory. While this will work, I'm not sure how well it will scale, and what the maintenance cost will be over time. It doesn't feel 100% "right" to me.</p></li> <li><p>Create a Facade between the business components and the UI tier. In this example, the Facade would have the checkout method and a reference to both managers. I like this approach more than the first, however I know that not all of my business objects will need a Facade, and I don't want to create a ton of Facade classes just to have empty pass through methods.</p></li> </ol> <p>I'm leaning towards 2, with the caveat that I will only create facade classes where needed. The UI tier will have access to both the Facade and the business layer components and will have to know when to use which (the only part I don't like about this solution).</p> <p>I've done a lot of research but haven't been able to come to come up with a solution that feels completely right.</p> <p>Any thoughts on using the facade pattern in this way, or other ideas to solve the problem are welcome.</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload