This is more of a subjective question, so I'm going to preemptively mark it as community wiki.
Basically, I've found that in most of my code, there are many classes, many of which use each other, but few of which are directly related to each other. I look back at my college days, and think of the traditional class Cat : Animal
type examples, where you have huge inheritance trees, but I see none of this in my code. My class diagrams look like giant spiderwebs, not like nice pretty trees.
I feel I've done a good job of separating information logically, and recently I've done a good job of isolating dependencies between classes via DI/IoC techniques, but I'm worried I might be missing something. I do tend to clump behavior in interfaces, but I simply don't subclass.
I can easily understand subclassing in terms of the traditional examples such as class Dog : Animal
or class Employee : Person
, but I simply don't have anything that obvious I'm dealing with. And things are rarely as clear-cut as class Label : Control
. But when it comes to actually modeling real entities in my code as a hierarchy, I have no clue where to begin.
So, I guess my questions boil down to this:
- Is it ok to simply not subclass or inherit? Should I be concerned at all?
- What are some strategies you have to determine objects that could benefit from inheritance?
- Is it acceptable to always inherit based on behavior (interfaces) rather than the actual type?