Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Re: Re: A different OO approach

by shotgunefx (Parson)
on Dec 15, 2002 at 22:42 UTC ( [id://220071]=note: print w/replies, xml ) Need Help??


in reply to Re^4: A different OO approach
in thread A different OO approach

I very much agree with "once and only once", my origins as a programmer were steeped in Asm and C. I realized quickly how it sucked cutting and pasting code (or making changes), then hunting down all the errors I cut and pasted. But on the other hand, I do a lot of CGI and including a dozen odd modules (and there includes) can quickly kill response time. (mod_perl isn't always an option.)

I'm not advocating people not use modules, but for myself, when it is something like this, were it amounts to a a few lines of code, I tend to keep it in a snippet file and cut and paste it into the source. In the simplest form..
sub add { my ($self,$name,$value) = @_; return if $name !~/^\w+$/; my $pack = ref $self; no strict 'refs'; *{$pack.'::'.$name} = sub : lvalue { $Attrs{+shift}->{$name} }; }
seems extreme for a module. On the other hand, if your attributes are more complex it could easily become worthy of using a module.

And yes I was confusing you with the poster, my bad.

-Lee

"To be civilized is to deny one's nature."

Replies are listed 'Best First'.
Re^6: A different OO approach
by adrianh (Chancellor) on Dec 15, 2002 at 23:08 UTC
    In the simplest form...seems extreme for a module.

    I'm afraid I'm the sort of weirdo who will write a module for a one-liner if it means I don't have to type it twice. I'll then code something to inline it automatically if efficiency proves to be an issue :-)

    On the other hand, if your attributes are more complex it could easily become worthy of using a module.

    It's not that they're more complex, it's that when I refactor code they tend to move around a fair bit between classes. Since I change them a lot, forgetting to tweak a DESTROY method or update a list of attributes is exactly what I'm likely to do. It's an artifact of my development style.

      I'm the sort of weirdo who will write a module for a one-liner if it means I don't have to type it twice. I'll then code something to inline it automatically if efficiency proves to be an issue :-)
      Heh, I was thinking just that while I was reading shotgunefx's post. That makes two of us I guess. :)

      Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2025-06-15 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.