GoF Patterns in Java (1997)
Minimal, runnable Java implementations of the five GoF patterns we used most at Motorola: Observer, Strategy, Factory Method, Decorator, and Command.
javadesign-patternsoop
GoF Patterns in Java (1997)
Each pattern lives in its own package with a *Demo.java entry point.
Contents
observer/— DeviceRegistry notifying AlertEngine and StatusDisplaystrategy/— SnmpV1 and SnmpV2 PollStrategy implementationsfactory/— MotorolaDeviceFactory creating typed NetworkDevice instancesdecorator/— CachingPollStrategy and RetryingPollStrategy wrapperscommand/— CommandHistory with execute/undo for device operations
Running
javac -d build src/**/*.java
java -cp build com.motorola.patterns.observer.ObserverDemo
java -cp build com.motorola.patterns.decorator.DecoratorDemo