Validation / Logic Layer architecture

  • Thread starter Thread starter djmc
  • Start date Start date
D

djmc

Hi,

I am working to clean up an application that is split into 3 major layers
(asp.net, logic, data).

In the logic layer, many of the methods seem to have a fairly lengthy
validation process, which is eventually followed by the real purpose of the
method. For instance, if I have a method that passes in a series of
parameters, each parameter is checked, validated and in the case of errors,
the appropriate message is generated to be passed back to the presentation
layer. Finally, if all the validation has passed, I can call the data layer
modules to perform the updates to the various tables.

Does it seem extreme to split this logic layer into two separate layers
(validation and logic)? Is there a cleaner way to perform validation in the
logic layer?

The methods always look similar to this:

If()
Createerror("msg")
Else if()
Createerror("msg")
Else if()
Createerror("msg")
Else if()
...
Else
{
DoLogic1()
DoLogic2()
DoLogic3()
}

Sometimes the validation is really long. hheh, and it makes me sad.

Oh well.. If this is a small issue and nobody really worries about this,
then please let me know too!
 
It makes very good sense to split the applicaiton up into layers, but
validation should occur in the presentation and the business (logic) layers.

For example, if you are asking someone to enter their date of birth on a web
page, then in the presentation layer code, you should be validating that
what was entered is, in fact, a date. Later on, in the business layer, you
can check it to see if it is the "correct" date (i.e. isn't a date in the
future, isn't a date that would make your user 200 years old, etc.).
 
ok thanks. I guess that's pretty much the split I already have going.
thanks for the response
 
Back
Top