Singleton, Observer, Factory, Adapter, Façade, Proxy
This post explains six common design patterns—with exam tips, examples, and quick reference tags.
In a Nutshell
Design patterns provide time-tested solutions to recurring structural and communication problems in software.
Quick Reference
- Singleton: Ensures a single instance across the application (e.g., configuration manager, logger)
- Observer: Implements publish/subscribe for event handling (e.g., UI updates)
- Factory: Encapsulates object creation logic
- Adapter: Makes incompatible interfaces work together
- Façade: Provides a simplified API over a complex subsystem
- Proxy: Acts as a gatekeeper for access control, caching, logging, or lazy loading
Key Exam Points
- Singleton: one instance, global access point
- Observer: decouples event producers from consumers
- Factory: flexible, centralized object creation
- Adapter: enables integration of incompatible components
- Façade: reduces API complexity
- Proxy: enforces access control and caching
- Always document and justify pattern choices
Core Components
- Singleton constructor pattern
- Observer interface contract
- Factory
create()method - Adapter mapping logic
- Façade API layer
- Proxy access control 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, proven solutions
- Established best practices
- Improves team communication and code reviews
Weaknesses
- Misapplication leads to unnecessary complexity
- Singleton can complicate unit testing
- Observer chains can trigger unexpected cascades
Common Exam Questions (With Brief Answers)
-
What does Singleton achieve? Guarantees exactly one instance of a class.
-
When should you use Observer? When multiple objects need to react to state changes independently.
-
Why use Factory instead of
neweverywhere? To centralize and decouple creation logic from client code.



