OOD: All classes at bottom of hierarchy contain the same field
Posted
by
My Head Hurts
on Programmers
See other posts from Programmers
or by My Head Hurts
Published on 2012-11-30T16:15:34Z
Indexed on
2012/11/30
17:19 UTC
Read the original article
Hit count: 337
object-oriented
|object-oriented-design
I am creating a class diagram for what I thought was a fairly simple problem. However, when I get to the bottom of the hierarchy, all of the classes only contain one field and it is the same one.
This to me looks very wrong, but this field does not belong in any of the parent classes. I was wondering if there are any suggested design patterns in a situation like this?
A simplified version of the class diagram can be found below.
Note, fields named differently cannot belong to any other class
+------------------+
| ObjectA |
|------------------|
| String one |
| String two |
| |
+---------+--------+
|
+---------------+----------------+
| |
+--------|--------+ +--------|--------+
| ObjectAA | | ObjectAB |
|-----------------| |-----------------|
| String three | | String four |
| | | |
+--------+--------+ +--------+--------+
| |
| |
+--------|--------+ +--------|--------+
| ObjectAAA | | ObjectABA |
|-----------------| |-----------------|
| String five | | String five |
| | | |
+-----------------+ +-----------------+
ASCII tables drawn using http://www.asciiflow.com/
© Programmers or respective owner