To subclass or not to subclass
Posted
by
poulenc
on Stack Overflow
See other posts from Stack Overflow
or by poulenc
Published on 2010-12-30T19:33:33Z
Indexed on
2010/12/30
19:54 UTC
Read the original article
Hit count: 442
I have three objects; Action, Issue and Risk. These all contain a nunber of common variables/attributes (for example: Description, title, Due date, Raised by etc.) and some specific fields (risk has probability). The question is:
Should I create 3 separate classes Action, Risk and Issue each containing the repeat fields.
Create a parent class "Abstract_Item" containing these fields and operations on them and then have Action, Risk and Issue subclass Abstract_Item. This would adhere to DRY principal.
© Stack Overflow or respective owner