Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

thepler (6873)

  (email not shown publicly)
+ -

  Comment: My rule of thumb... (Score 1) on 2009.05.27 17:01

by thepler on 2009.05.27 17:01 (#68806)
Attached to: Inheritance or Roles?
Here's what I've been using:

If you don't want instances of it, then it's not a class. In which case it's possibly (probably?) a role.

So if you've got Foo and Bar and you're not sure if if you want "Bar does Foo" or "Bar isa Foo", then ask yourself if you want Foo->new(...) to work. If you do, then Foo is clearly a class and you want "Bar isa Foo". Otherwise Foo should be a role and you have "Bar does Foo".

If you do want Foo->new(...) to work, I suppose you can get around having an isa relationship by making a MyRole and say that "Foo does MyRole" and "Bar does MyRole". But then take Stevan's point about "Is this a true is-a relationship?" and wonder if you're just being a bit too role-happy.
Read More 9 comments
Comments: 9