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: 411

Filed under:
|
|

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:

  1. Should I create 3 separate classes Action, Risk and Issue each containing the repeat fields.

  2. 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

Related posts about oop

Related posts about design