Comment: My rule of thumb... (Score 1) on 2009.05.27 17:01
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
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.
