Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Re: use base 'Foo' or die!

by ihb (Deacon)
on Feb 12, 2003 at 18:53 UTC ( [id://234797]=note: print w/replies, xml ) Need Help??


in reply to Re^2: use base 'Foo' or die!
in thread use base 'Foo' or die!

So tell me, how often do you have to inherit from another class at a later time?

You seem to have missed the whole point of my post. Let me extract the key sentences in my already short reply: "... and there [with imports lists etc] it's handy when you want to add something to the list /.../ though having a list of more than one element there [with base.pm] would be the exception, not the rule"

I tend to use qw() for the same reason I tend to add a , after the last element of a long array. It's less work if I have to add something else at a later date.

Hmmm, is it more work to add the comma when you append to the list? It seems like it's the opposite. It's more work to add commas everywhere that I might not use. However, I use tailing commas too. And too out of laziness. But not because I want to add stuff later. Instead it's because if I want to reorder the list it's quite smooth if all lines can be treated equally when cutting and pasting.

ihb

Replies are listed 'Best First'.
use base qw(Foo) && confess "I hate single-quotes"
by dragonchild (Archbishop) on Feb 12, 2003 at 20:34 UTC
    So tell me, how often do you have to inherit from another class at a later time?

    A lot more often than it seems I should, actually. I do a lot of rapid OO prototyping, often before I want to propose a new design. As such, I don't have a design laid out and agreed upon yet. So, I'll try different things, move things around, try and figure out where things really want to live vs. where I think they should live.

    How often have I used MI? Less than a handful. How often have I thought of using MI during rapid prototyping? Too often to count.

    That's why I use base qw(Foo);

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: Re: Re: Re: use base 'Foo' or die!
by extremely (Priest) on Feb 12, 2003 at 23:01 UTC
    I wouldn't characterize adding the comma at the end of the list to be work saving because it saves you adding the comma later.

    What it saves you is editing the file twice when you do a line copy in your favorite editor (Yp in vi, for example,) to add that most recently discovered forgotten item and wind up with:

    my %blah = ( one => 1, two => 2, three => 3 four => 4 );

    And back you go for a single comma. If the last line has a comma, you can yank any line you want and can be sure it is safe to paste a copy back in. Adding the comma is for us non-perl-parsing-robot types who suffer from excessive human flaws. :) :)

    See page 74 of the 3rd Camel, Larry and Tom thought to mention the benefit of null list items and optional terminating commas!

    Update: ihb points out I skimmed the last couple lines from his post and missed that he does tailing commas for reordering. Oops. Still, my point goes to reordering the same as his, the tailing comma is 2nd order laziness: microscopic extra work now can save you quite a bit more work later. Adding the comma is essentially cost-free, but leaving it out means editing multiple lines when you edit, add, reorder, or remove from any list.

    --
    $you = new YOU;
    honk() if $you->love(perl)

Re^4: use base 'Foo' or die!
by adrianh (Chancellor) on Feb 13, 2003 at 10:24 UTC
    So tell me, how often do you have to inherit from another class at a later time?

    Fairly often - that's why I said it ;-)

    I find that I add MI (usually only temporarily) during refactoring. A class pops out from another class, becomes an inherited subclass for a bit, and usually ends up in a has-a/implemented-with relationship in the end. So I can start out with single inheritence, move to multiple, and come back to single again.

    Using qw() consistantly makes things easier for me.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-16 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found