#perl - Wed 7 Mar 2007 between 10:22 and 10:03



kyrbemerlyn, can you suggest a good book for learning about objects ;)
merlynyou jest. :)
Why, my book of course. :)
LeoNerd</plug>
yrlnryNever write a subroutine less than 100 lines. Subroutine calls are expensive.
merlynheretic!
never write a subroutine that doesn't return a coderef. :)
kyrbeyeah, what's the reasoning behind smaller subs?
merlynit forces you to NAME each step
yrlnryI was going for "diabolical", but if "heretic" is the best I can do, I suppose I'll have to settle for that.
merlynmore self documenting
also, when you're doing OO, it's easier to subclass and override parts
LeoNerdObject accessor methods tend to be quite short
yrlnryI write all my Perl programs in continuation-passing style.
merlyn200-line subroutines are the death of subclassing
I pass discontinuations. :)
LeoNerdsub thing { my $self = shift; return $self->{thing} }
merlynoh - and don't automatically write accessors for all instance vars.
people who do that should be shot.
they end up with objects that are nothing more than structs.
kyrbeI was told yesterday not to use shift b/c it destroys @_. Any other comments on this?
LeoNerdOh, sure... but in cases where you expect subclasses to override.. it's good
merlynI'd destroy that person
that's silly advice
LeoNerdDepends if you want to
I often go my $self = shift; my ( $arg, $names, $here ) = @_;
merlynexport behavior, not data
yrlnrykyrbe: sounds like terrible advice.
merlyndefine your interfaces in terms of what you want the object to do, not what you think the object should know
you shouldn't care what the object knows.
LeoNerdMmm.. Sounds good
merlyntherefore, automatic accessors by default are wrong
certainly, a Point will need an X/Y when creatd
but you shouldn't care if it stores those as two separate vars, or some single encoded value
and you'd probably want a "get x coordinate of point" if it makes sense in your app
but what if your app never cared about that?
why write code to return "x"?
it's all about paying attention when you design
and automatically generating accessors makes you not pay attention, and that leads to bad practices.
& morning stuff

Page: 1 8 15 22 29 36 43 50 57 64 71 78 

IrcArchive