in reply to Re^3: defining methods on the fly
in thread defining methods on the fly
What the OP actually said is
I['m] sure this breaks some rules of good programming practice,
Which reads to me a little like someone saying "I'm sure that it will offend someone somewhere for me to say this, but I really enjoyed the dog stew I was served in Cambodia"*.
Given that site:cpan.org autogenerate methods a very quick query of CPAN shows up a large number of modules that either autogenerate methods for their own use, or provide the facility of autogenerating accessors and mutators for use by other class modules. And that many of these are written by some of Perl's biggest and most respected names. The basic idea is far from a uniquely obscure, dangerous or obviously "bad practice".
Indeed, there is a strong argument that one of the major benefits of using a dynamic language is the ability to write code that generates code. This is epitomised by the Once And Only Once practice design principle of XP fame and was (I think) originally advocated in the book, The Pragmatic Programmer: From Journeyman to Master, which is generally very highly regarded.
Without critiquing the OP's implementation, the basic idea is far from a "bad programming practice", and it is anonymonk's somewhat kneejerk reaction to the OP's use of the word "cool" that I was addressing.
*I've never been to Cambodia!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: defining methods on the fly
by ptum (Priest) on Aug 03, 2006 at 15:55 UTC | |
by chromatic (Archbishop) on Aug 03, 2006 at 18:02 UTC | |
by ptum (Priest) on Aug 03, 2006 at 19:10 UTC | |
by chromatic (Archbishop) on Aug 03, 2006 at 21:29 UTC | |
|
Re^5: defining methods on the fly
by Anonymous Monk on Aug 04, 2006 at 00:20 UTC |