Back to list
Views:   11K
Replies:  2

How does one handle business rule messages between layers?


I have an n-tier layer application.
I want to handle  business rules messages and show client user-friendly messages.

For example, the email entered is not unique and cannot be added to the database. 
How do you handle this validation rule between the layers (DAL,PLL,BLL)?


Best Regards.
Volkan Genç, Jun 07, 2012
Reply 1
I suggest you to utilize the Builder Design Pattern in this case.
Please follow the instructions in my blog 
Pradip Shrestha, Jun 14, 2012
Reply 2
There are many different ways to handle this type of response.

Some of them are:
  1. Ajax - in your UI (if this is a web app) trigger an Ajax call to the repository to validate a unique name, so the response is instantaneous and a nice user experience
  2. Business Objects - add some logic to your business objects that does this validation (which will query the repository)
  3. Custom Validator Object - create some custom validator class that can handle this for any rules on any request.  You UI objects can call a method on the validator object to validate the rule
  4. Data objects - don't put anything anywhere except in your data objects that does this check prior to an insertion or update

The process you choose is generally determined by the structure of your application.  There are most likely many other ways of achieving this, but these are some ideas.

Regardless of how you handle this, you can always provide your own friendly responses back to the UI.

I hope this helps.


King Wilder

King Wilder, Jun 11, 2012
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.