Forum Post: Re: Data Validation Approach

  • Thread starter Thread starter Tim Kuehn
  • Start date Start date
Status
Not open for further replies.
T

Tim Kuehn

Guest
My usual practice is to separate the domain and validation logic so I can use either of them when and how I wish. The advantage is that I can populate the domain instance in an incremental manner that could include contextual circumstances that would otherwise be illegal -or- I could use the same domain object different ways and then validate it according to the validation rules that apply in the current context by using the appropriate validator class. This structure not only results in more flexibility, it also allows me to use the validation code to check other non-domain objects & contexts. Splitting the two types of logic allows you to go with both of your proposals - subclass the current class, create the validation logic as a separate class, and then either have the new ContentTypeHeader subclass call your validation logic -or- the customer developer can pass their HttpHeader class to your new ValidateHttpHeader class to do the check at the appropriate time.

Continue reading...
 
Status
Not open for further replies.
Back
Top