Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Class automators should be standard

by rkg (Hermit)
on Jan 14, 2004 at 20:52 UTC ( [id://321364]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Class automators should be standard
in thread Class automators should be standard

Ok, I'l agree with your point about making the computer do the boring repetitive stuff.

But back to my question:

How do you handle getter/setters when the attributes interact? In your shipping example, what would keep me from (assuming I understand the methods correctly) setting  from_state to Massachusetts and is_from_west_coast to TRUE? Shouldn't setting the state cause the west coast flag to flip on or off as appropriate?

A handrolled get/set could enforce all these things; doesn't C:MM fall short here?

I am not C:MM bashing; I use it and am a fan; I just haven't figured out how to handle interrelated attribs yet.

Thanks for your comments

rkg

Replies are listed 'Best First'.
Re: Re: Re: Re: Class automators should be standard
by danb (Friar) on Jan 15, 2004 at 03:16 UTC

    Your point is a good one. It is necessary to hand-roll methods that do anything non-simple, like keeping is_from_west_coast() in the correct state.

    Because of that, C:MM can only be used for simple methods. In my case, that means C:MM methods are usually private methods, and public methods are hand-rolled.

    I am looking forward to automatic method constructors getting smarter in the future. I could imagine a module that combines something like Params::Validate with C:MM, like so:

    use Class::MethodMaker optional => [ 'zone_file' => [ 'no spaces', 'alpha only', 'uppercase', 'error on parameter failure' ] ];

    -Dan

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-19 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found