Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
It is possible to invoke the DAL directly from the code behind and this would work in the Patterns in Action example.
However, this wouldn't be a good idea. 

There is several reasons for having a Service Layer. Two important ones are 
  • Validation, and 
  • Transaction Management 
Validation: The best place for complex business rule validation is the service layer. Here is an example of a complex rule: only approve a loan application if the user is 18 years or older, has a credit history, has a bank account with the financial institution, and has lived in the same house for at least 1 year. 

Transaction Management: When multiple objects are committed to the database, you will want to do this within the context of a transaction (Unit of Work pattern).  The Art Shop has a good example in which the content of the shopping cart are turned into an order. This involves DELETES and INSERTS in 4 tables, and the transaction ensures that the entire process either fails or succeeds, so there are no situations where half of the shopping cart is an order and the rest is still in the cart. 

Hope this helps. 





Jack Poorte, Aug 26, 2013
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas