Views: 4.4K
Replies: 1
Archived
|
What is the point of a service layer in Patterns in Action 4.5?As far as I can tell the Service class mostly just wraps DAO calls. If there is only one consumer of the service (e.g. one win form application), then what is the point of a service layer? What's the big deal in just calling the DAL directly from the winform application?
Mr. Query, Aug 20, 2013
|
|
Reply 1It 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
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
|