|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Good day,
First of all, sorry for my English, it is not my mother tongue. Here is a simplified version of my problem. I got a web form that construct a RegisterForm object. That RegisterForm object contains a collection of Options. After that the form as been submitted, I construct a RegisterForm object that contains a collection of Options based on the form fields. Then, I pass that RegisterForm object to my business layer, to insert it into the database Here is my question: The collection of Options objects in the RegisterForm has to be validated. For example, the user cannot select the Option A and B together, but can select Option A and C. What is the best practice for validating it? Is it by creating a AreOptionsValid() in the RegisterForm object? Is it by wrapping the collection of Options in a TheOptions class and call IsValid on it? Of course, the real system is more complex and I don't wanna validate the collection of Options in the web form, I have to validate it in the business layer. And if the collection is not valid, what should I return to the web form... A custom exception? A OptionsError object? So what are your thoughts about that? I am looking for the best practices here. Thank you very much! |
| Sponsored Links |
|
|
|
|||||
|
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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Animated Ripple effect (Simple) - Flash MX 2004 | ahsan16 | Photoshop Tutorials | 10 | 05-22-2008 06:54 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%