in reply to Writing general code: real world example - and doubts!

I read through all the replies, and there's one pattern of data valdation I've always liked: rule based. You'd create an engine that you plugged in some sort of configuration space. Each rule would have a method to determine if the input passed is valid or not. If it is, a positive effect occurs. True is returned, an exception is not thrown.. something. On failure, false or an exception is created.

For perl, I would imagine a system where everything must implement a base Rule object. The engine would create one of each rule and have some sort of "validate" function. Next, wrap whatever framework away from the developer. Your Wrapped framework would have a method for getting data, "get_validated_data" which would take a pointer to your validator configuration as to which object to use. I would then be able to do something ala...

my $frameWork = WrapedFrameWork->new(); my $allValid = 1; my ( $valid, $data ) = $frameWork->get_validated_data("email","typeEma +il"); $allValid &= $valid; if( !$allValid ) { .... }
If your developers do code reviews, which they should, any bypassing the system can be slapped down. New validators can be written for everyone to use. Life may be cleaner.. in an ideal world 8)

----
Give me strength for today.. I will not talk it away..
Just for a moment.. It will burn through the clouds.. and shine down on me.