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
+------------------+
| NoteMapping |
|------------------|
| String noteId |
| String content |
| |
+---------+--------+
|
+---------------+----------------+
| |
+--------|--------+ +--------|--------+
| UserNote | | AdminNote |
|-----------------| |-----------------|
| String userId | | String adminId |
| | | |
+--------+--------+ +--------+--------+
| |
| |
+--------|--------+ +--------|--------+
| UserBookNote | | AdminBookNote |
|-----------------| |-----------------|
| String bookId | | String bookId |
| | | |
+-----------------+ +-----------------+
ASCII tables drawn using http://www.asciiflow.com/
Edit
I have added some class and field names to the class diagram above.
The reason bookId
cannot exist in any of the parent classes is because it is used to create a OneToOne
relationship with another class - which is not something that we always want to do.
this field does not belong in any of the parent classes
-- Why?