Parallel Class/Interface Hierarchy with the Facade Design Pattern?
Posted
by
Mike G
on Programmers
See other posts from Programmers
or by Mike G
Published on 2013-08-07T17:33:27Z
Indexed on
2013/11/06
10:11 UTC
Read the original article
Hit count: 277
About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line
). Naturally, it delegates responsibilities to the subsystem behind it.
What ends up happening is that two of the subsystem classes (Output
and Timeline
) have all of their methods duplicated in the Line
class, which effectively makes Line
both an Output
and a Timeline
. It seems to make sense to make Output
and Timeline
interfaces, so that the Line
class can implement them both. At the same time, I'm worried about creating parallel class and interface structures.
You see, there are different types of lines AudioLine
, VideoLine
, which all use the same type of Timeline
, but different types of Output
(AudioOutput
and VideoOutput
, respectively). So that would mean that I'd have to create an AudioOutputInterface
and VideoOutputInterface
as well. So not only would I have to have parallel class hierarchy, but there would be a parallel interface hierarchy as well.
Is there any solution to this design flaw?
Here's an image of the basic structure (minus the Timeline class, though know that each Line has-a Timeline):
NOTE: I just realized that the word 'line' in Timeline
might make is sound like is does a similar function as the Line
class. They don't, just to clarify.
© Programmers or respective owner