in reply to Re: Convenient Constructors - a Moo question
in thread Convenient Constructors - a Moo question

Thank you for the reply, but I cannot agree with you on this one. Subclassing would be useful if the new classes would add anything to the base class. It seems completely unnecessary here, when the only difference between a Heavy Attack and a Light Attack is the set of attribute values.

The association between seeing subtypes of anything and thinking about inheritance as a possible solution is a natural one, but it's not always a good thing. It even has it's own section in Ovid's excellent Often Overlooked OO Programming Guidelines. To quote the first couple of sentences in "Don't subclass simply to alter data":

Subclass when you need a more specific instance of a class, not just to change data. If you do that, you simply want an instance of the object, not a new class. Subclass to alter or add behavior.

- Luke

  • Comment on Re^2: Convenient Constructors - a Moo question

Replies are listed 'Best First'.
Re^3: Convenient Constructors - a Moo question
by davido (Cardinal) on Dec 07, 2014 at 05:09 UTC

    Eh... I have to admit that within a few minutes of making my post I wasn't so convinced either. ;)


    Dave