Dofactory.com
Dofactory.com
 Back to list
Views:   3.9K
Replies:  0
Archived

Where to add complex logic in a repository layered application like patterns in action (4.5)

Hi here,

I have a validation rule question about the patterns in action application:

Sometimes it's necessary to perform complex validation logic with have a heavy database load cost. Example: A member may only be deleted, when all business related members are deleted. Like: Partner/Consumer principle -> partner cannot be deleted when it has 1 or more consumers. All consumers must be deleted first, before the partner can be deleted.

Question:
Where's the best place to put these complex logic in the application? Is it in the business logic layer, but when/how is the best time to load the database data to able to perform the validation logic (it shouldn't be loaded every time a member is loaded)? Or is it the service layer or some where else?

Note:
In the patterns in action example could a member only deleted when it has no orders. This validation logic is done in the presentation layer. I think it shouldn't be in the presentation layer because all these logic must be implemented in all presentation layered projects (MVC, Forms, WinForms and WPF). And in addition, if you want to pre-validate before deleting, this functionality should execute the same validation logic of the same code base (to prevent inconsistency between pre-validation and validation logic).


All kind of answers / thoughts are welcome. Thanks in advance,

Regards,

J. Damminga
The Netherlands


J Damminga, Apr 29, 2014
I'm not sure how you define business logic layer and service layer. Both seem similar to me. But that is where I'd do validations. Especially if they are business rules. I suppose a case could be made to do the check in the data layer too.
May 02, 2014
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.