7

Boss Battles

The patterns you confuse the most. Fight each pair until the difference is burned in.

VS
StrategyVSState

Both swap behavior via composition. One changes based on client choice, the other based on internal state.

Confusion score: 0
VS
Factory MethodVSAbstract Factory

One creates a single product via subclassing. The other creates families of related products.

Confusion score: 0
VS
Simple FactoryVSFactory Method

One is a method with a switch. The other uses inheritance to defer creation to subclasses.

Confusion score: 0
VS
BuilderVSFactory

One builds step by step. The other creates in one shot.

Confusion score: 0
VS
AdapterVSFacade

One wraps one class to match an interface. The other simplifies a whole subsystem.

Confusion score: 0
VS
AdapterVSDecorator

One changes the interface. The other keeps the interface but adds behavior.

Confusion score: 0
VS
DecoratorVSProxy

Both wrap an object. Decorator adds behavior. Proxy controls access.

Confusion score: 0
VS
ObserverVSMediator

Observer is one-to-many notification. Mediator centralizes complex communication between peers.

Confusion score: 0
VS
ObserverVSPub-Sub

Observer has direct coupling between subject and observers. Pub-Sub has a broker in between.

Confusion score: 0
VS
CommandVSStrategy

Both encapsulate behavior. Command is about actions (do/undo/queue). Strategy is about algorithms (swap at runtime).

Confusion score: 0
VS
Template MethodVSStrategy

Template uses inheritance to vary steps. Strategy uses composition to vary the whole algorithm.

Confusion score: 0
VS
CompositeVSDecorator

Both have recursive structure. Composite models part-whole trees. Decorator wraps to add behavior.

Confusion score: 0
VS
BridgeVSAdapter

Adapter fixes an existing mismatch. Bridge is designed upfront to separate abstraction from implementation.

Confusion score: 0
VS
Chain of ResponsibilityVSDecorator

Both chain objects. CoR can stop early. Decorator always passes through and adds behavior.

Confusion score: 0
VS
SingletonVSStatic / DI Singleton

Classic Singleton controls its own lifecycle. DI-managed singletons are created by the container.

Confusion score: 0
VS
InheritanceVSComposition

Inheritance is is-a (fixed at compile time). Composition is has-a (flexible at runtime).

Confusion score: 0
VS
DIVSIoC / DIP

DI is a technique. IoC is a principle. DIP is a SOLID rule. They are related but not the same.

Confusion score: 0