View Single Post
  #2 (permalink)  
Old 06-22-2008, 12:15 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,568
Last Blog:
Tidy up your HTML
Credits: 0
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Validating a collection in business layer: best practices

I do not believe the Business Layer should be responsible for validation. In my framework, I have a class that us used strictly for common validation purposes (valid email address, web address, ect...). I would suggest you create a separate class for your validation thus creating a more decoupled code (you never know when it will be used again).

As for what to do when your collection is not valid, I would simply print out an error. I use exceptions when there could be errors PHP cannot recover from. This provides an elegant way to exit the application. A invalid object can easily be handled by you, without exiting the application.
Reply With Quote