Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re(4): RFC - Parameter Objects (validation)

by hossman (Prior)
on May 14, 2003 at 21:35 UTC ( [id://258263]=note: print w/replies, xml ) Need Help??


in reply to Re(4): RFC - Parameter Objects (validation)
in thread RFC - Parameter Objects

Perhaps the contructor could be modified. The current hashref would fall under a key named "params" and a different key named "groups" would list group validations. Then, as soon as an accessor is called, the "group" validations would be checked. This would eliminate the order dependence. Workable?

This still leaves it up to the person constructing the Params object ot specify what the overall validation function is ... maybe the %params hash is some global that gets re-used by all of the clients -- because if they don't then the method they are passing the Params too will fail when it tries to access things with a certian name -- but they can allways just choose to not pass a "groups" test and circumvent the tests.

I would recommend approaching this problem form a different direction -- seperate the "definition" of what a valid Param object is for a given context, from the "instantiation" of a particular instance.

Consider something like this...

#### in the library code ### Sub::Param::make_new_param_type($param_type_name \%param_definitions, \&validity_function); ... sub some_method { my $param = shift; die "die" unless $param->isValid($param_type_name); ... } sub some_other_method { my $param = shift; die "die" unless $param->isValid($param_type_name); ... } ... ### in some client ... my $p = new Sub::Param($param_type_name); $p->foo(1); $p->bar('Toledo'); SomeLibrary::some_method($p); ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://258263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found