Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Making up your mind on an API lets you change the implementation later on without too much refactoring madness. If you only access and modify attributes through methods (choose any of setField/getField or set_field/get_field or field or whatever you consider best) you can decide at a later moment to change the implementation from hash to inside-out object without the need to check all the code using a class. Recently I have been using a module of my own which works well enough for my needs and has let me learn a bit about dynamic function creation. If a class Hero needs scalar fields name, nick and strength and array fields friend and woe, then I declare it like this: BTW::Class takes care of creating an "intermediate" package Hero::BTWClass, populating it with all accessor and mutator methods. Hero::BTWClass is appended to Hero's @ISA. There is a unique hash of hashes containing the structure of all objects, indexed by the numeric object reference. This keeps the actual objects "clean" as in inside-out objects. This way:
Antonio Bellezza The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket In reply to Re: Which Perl 5 Object System to Use?
by abell
|
|