Singleton, Observer, Factory, Adapter, Facade, Proxy
This post is a quick reference to six common patterns, complete with exam prep, examples, and key takeaways.
In a Nutshell
Design Patterns provide proven solutions to recurring structural and communication problems.
Quick Definitions
- Singleton: ensures exactly one instance (e.g., configuration, logger)
- Observer: implements Publish/Subscribe for events (e.g., UI updates)
- Factory: encapsulates object creation
- Adapter: translates incompatible interfaces
- Facade: presents a unified, simple API for a subsystem
- Proxy: acts as a stand-in for access control, caching, logging, and lazy loading
Exam Essentials
- Singleton: single instance, global access
- Observer: event decoupling
- Factory: flexible object creation (key for IHK exams)
- Adapter: integration and compatibility
- Facade: simplified interface
- Proxy: access control and caching (security)
- Always document and justify pattern choices
Core Components
- Singleton constructor pattern
- Observer interface contract
- Factory
create()method - Adapter mapping logic
- Facade API layer
- Proxy access gate
Practical Example (Singleton in Java)
public class ConfigManager {
private static ConfigManager instance;
private ConfigManager() {}
public static ConfigManager getInstance() {
if (instance == null) {
instance = new ConfigManager();
}
return instance;
}
}
Strengths and Weaknesses
Strengths
- Reusable solutions across projects
- Battle-tested structures
- Improved team communication
Weaknesses
- Misapplication leads to unnecessary complexity
- Singleton can complicate unit testing
- Observer chains can cascade unintentionally
Common Exam Questions (Quick Answers)
- What does Singleton achieve? Guarantees exactly one instance.
- When should you use Observer? When multiple objects need to react to a state change.
- Why use Factory instead of calling
neweverywhere? It centralizes and decouples creation logic.



