//--- OUTPUT /* Factory 1 constructed • Product A1 constructed • Product B1 constructed • Doing A1 operation • Doing B1 operation • Product A1 destructed • Product B1 destructed Factory 1 destructed Factory 2 constructed • Product A2 constructed • Product B2 constructed • Doing A2 operation • Doing B2 operation • Product A2 destructed • Product B2 destructed Factory 2 destructed */
Rma MACDProgramming Patterns - Observer
When the subject changes, it notifies and updates its observers, who know nothing about each other.
Define an interface for creating an object, but let subclasses decide which class to instantiate. Lets a class defer instantiation to subclasses.Programming Patters - Builder (classic)
Separate the construction of a complex object from its representation so that the same construction process can create different representations.