I came up with it after seattlejohn thanked me for my code. He said "seriously, your code does some really slick stuff to make it easier for the caller, which i really like..." This statement prompted me to think of what I'd done. I'd allowed the module to be used very simply:
instead of the clunky:use Tie::Scalar::Watch; my $x = 10; watch { $x > 5 } $x;
I'd used Perl to my advantage to create a pseudo-syntax (thanks to the "&" prototype). The code is easy to read and makes sense with little explanation. The fact that you can use the variable you're watching in the assertion-function itself is nifty.use Tie::Scalar::Watch; my $x = 10; tie $x, 'Tie::Scalar::Watch', $x, sub { $_[0] > 5 };
So my motto means "make things easy for yourself, while keeping them easy for other people too." Don't use convoluted syntax because you can (that doesn't mean "don't use idioms") or because it shows you're elite. Use syntax that you are proud of, and that other people can appreciate. It is to that end that I created a module (to be released soon) called Tie::Array::Unique -- it ensures the elements of an array are unique, so you don't need to keep track with a hash (it does it for you).
Tie-modules are a very good example of this motto. They keep the icky internals away from the implementation, and produce a syntax that is quite normal (since it's just overloading the standard operations on data structures).
So that's my motto. Any feelings? Any personal mottos out there for the sharing?
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: I feel a motto coming on...
by tretin (Friar) on Jan 13, 2002 at 23:31 UTC | |
Re: I feel a motto coming on...
by n3dst4 (Scribe) on Jan 13, 2002 at 23:06 UTC | |
by japhy (Canon) on Jan 13, 2002 at 23:36 UTC | |
by helgi (Hermit) on Jan 15, 2002 at 18:06 UTC | |
Re: I feel a motto coming on...
by jonjacobmoon (Pilgrim) on Jan 13, 2002 at 23:30 UTC | |
Re: I feel a motto coming on...
by petral (Curate) on Jan 14, 2002 at 18:36 UTC | |
Re: I feel a motto coming on...
by tamills (Acolyte) on Jan 15, 2002 at 01:43 UTC | |
by tretin (Friar) on Jan 15, 2002 at 03:14 UTC | |
Re: I feel a motto coming on...
by seattlejohn (Deacon) on Jan 15, 2002 at 13:02 UTC |