Namespace Organization - AOP Validators

I started using aspects to validate parameters in our development framework. It works nicely and I like not to litter the first half of the public method with validation code.

I'm wondering if anyone has any advice as to where in the namespace structure you would put parameter validation? Part of me thinks that because it is a top-level functionality, it should be in the top-level product namespace - just like how the system is used in the .NET Framework. I'm just worried about prying a kernel build with a lot of features like this as it goes further down the line.

Since it is standing right now, I have them in something like:

[About company]. [Product] .ParameterValidators

In this example, ParameterValidators is the name of the class (aspect) that contains the functionality.

Also, I would appreciate it if anyone had any further advice on how to incorporate aspects into the existing codebase in regards to structural placement.

+1


source to share


1 answer


Right now you are considering a separation using technical criteria i.e. "Put all validators in the namespace because they are validators." This does not account for the reason why validators exist.

My suggestion is to split by functionality:



  • Generic validators (such as invalidation and range checking) go into the generic namespace.

  • More specific validators (such as ClientValidators) fall into more specific namespaces.

The general idea is that you don't have 1 class that contains all possible validators, you have several classes (in different namespaces), each of which declares a validation for a specific reason.

+1


source







All Articles