External ValidationManager???

External ValidationManager???

Old forum URL: forums.lhotka.net/forums/t/3967.aspx


SonOfPirate posted on Friday, November 30, 2007

I'm sure this has been discussed before but I am unable to find anything searching through the forum...

Has anyone considered using or implemented an external component to manage validation rules and perform validation rather than holding instances of the ValidationRules class for each type of business object?

I am working on an application where the memory footprint has grown significant due to the manner in which users make use of the app so we are doing quite a bit of profiling on how the app utilizes memory.  The addition of per-type validation rules is certainly a significant step forward, however there is still some overhead to having an instance of the ValidationRules class for each business object type.  It has occurred to me that we could possibly pull this out of our business objects and have them collaborate with another component, ValidationManager, for instance (essentially a dictionary of ValidationRules objects keyed by type).  Instead of holding an instance of the class in a private variable, our AddBusinessRules method would be refactored to call ValidationManager.AddRule instead.  The ValidationManager class would manage the list of rules for each type and instance.  To perform validation, our business objects would delegate to the ValidationManager.Validate(this) method - notice the argument which is used by the ValidationManager to perform both per-type and per-instance checks if they exist.

I'm looking for arguments for and against this approach so we can make a more educated decision if it would be beneficial to refactor our code in this way.

Thanks in advance.

 

RockfordLhotka replied on Saturday, December 01, 2007

The only reason I didn't do this in CSLA itself is to preserve the per-instance capability.

But I wonder how many (if any) people actually use that ability after upgrading to 2.1+?

I know I never use it, I only use per-type rules. Nor do I directly know anyone who is using per-instance rules.

So it does make me wonder if I shouldn't just drop per-instance support at some point (like in 3.5).

JoeFallon1 replied on Saturday, December 01, 2007

I am only using per type rules.

I have a general rule class like yours for common rule methods.

I also use the strongly typed rule methods in a given class if the rule is specific to it and I need access to member variables. But it is still a per type rule.

Joe

 

RockfordLhotka replied on Saturday, December 01, 2007

Yeah, exactly. I use a lot of rules implemented in specific business classes, but I haven’t used a per-instance rule since I changed everything in 2.1.

 

Rocky

 

 

From: JoeFallon1 [mailto:cslanet@lhotka.net]
Sent: Saturday, December 01, 2007 4:59 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] External ValidationManager???

 

I am only using per type rules.

I have a general rule class like yours for common rule methods.

I also use the strongly typed rule methods in a given class if the rule is specific to it and I need access to member variables. But it is still a per type rule.

Joe

 



Copyright (c) Marimer LLC