This is my situation:
I have a class called CueList, which is basically a wrapper around ArrayList. I have another class called
TimeTicker that alerts all the
Tickable (interface) in its list that a certain amount of time has passed. Since I need to tick all of the items in
CueList, but I don't want to violate DRY by keeping a copy of all of the CueList items in the
TimeTickable class as well (which would make a nightmare when I want to delete a Cue), my immediate instinct was to make
Tickable and have it pass on the "tick" message to all of its items.
This seems to violate the Single Responsibility principle, which says that
CueList should not worry about both keeping track of all the cues AND Ticking them.
So what I did was create a
CueManager class that is itself Tickable and links everything up (and ticks all of the CueList elements).
But now, because of the law of demeter, I have a bunch of duplicate methods in the
CueManager that just mirror the
Doesn't that mean that the
CueManager class has multiple reasons to change? Doesn't that mean it violates the Single Responsibility principle.
Also, since most of the methods in CueManager mirror TimeTicker and CueList, doesn't that really mean that it IS a TimeTicker and CueList. Therefor shouldn't it INHERIT from CueList and TimeTicker! (Obviously you can't do multiple inheritance in Java, but I feel like it sort of makes sense to Inherit from CueList, but then that would violate Single Responsibility)
So in summary:
Law of Demeter makes me make a bunch of methods that merror two other classes, but that makes me think that it really should just inherit from both of those classes, but that would mean that one class handles multiple responsibilities (even if it is through its superclass).