Passing Validation result between tiers??

  • Thread starter Thread starter Albert Tollkuçi
  • Start date Start date
A

Albert Tollkuçi

I have created a class ValidationResult which
looks like:
class ValidationResult
{
ValidationStatus Status;
ValidationItemCollection Items;
}
The ValidationItem is defined as below:
class ValidationItem
{
ValidationStatus Staus;
string Code; // Error code usually, but can be a warning, info or sth
else
string Message;
}
ValidationStatus is an enumeration which for the moment is defined as:
enum ValidationStatus
{
Success,
Failed
// Later can be added Warning, Info etc.
}
Now the problem is how to pass the ValidationResult object to the UI. I see
3 options:
1. throw an exeception which has a property of type ValidationResult. The UI
then can catch the exception and proceed. Looks a bit messy to me...
Pros: Force the UI to handel the validation.
Cons: Looks like a bad design. UI code would be messy...
2. Fire an event on a "global" object accessible from both UI and
components. "Recomment" the UI to attach an event handler...
Pros: UI code should be better organized...
Cons: UI is not forced to handle the event...
3. Use some kind of queue to add the ValidationResult objects from the
components and poll them from the UI.
Pros: ?
Cons: ?

Any thoughts are welcome.

Thanx,
Albert
 
Instead of this why cant you make the class as static and access the
validationstattus anywhere.It will be an good solution.
 
A static class is variation of the third option.
It can work, but it's not a good OO design...I'm not sure if it's the right
way to go...
 
A static class is variation of the third option.
It can work, but it's not a good OO design...I'm not sure if it's the right
way to go...

Forgive my ignorance. Are you talking about windows genuine
validation?


Greg Ro
 
Back
Top