A lot of patterns work together very well to form compound patterns. Below is a UML class diagram that implements various design patterns to form a compound pattern. After the diagram are some notes describing how and why this design was arrived at.
Quackableinterface. This makes a number of design patterns available to us.
quack()is called. Using the decorator pattern means we don't have to modify
Quackableso it can referenced as
Quackableinstance variable so it can be passed a
QuackDecoratoris the first object in the chain, so it's
quack()method is called first. This allows it to update a counter variable, then call the
Gooseclass, the adapter pattern is utilised so that we can convert the call to
Quackables quack()method. Note that
Quackableso we can refer to all our objects as the same