Useful Links
Computer Science
Programming
By Language
Java Design Patterns
1. Introduction to Design Patterns
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
5. Advanced Topics and Best Practices
Structural Patterns
Overview of Structural Patterns
Focus on Class and Object Composition
Goals of Flexibility and Efficiency
Common Characteristics
Comparison Framework
Adapter Pattern
Intent and Applicability
Problem Context
Solution Structure
Target Interface
Adaptee Class
Adapter Class
Implementation Variations
Object Adapter
Class Adapter
Two-way Adapter
Common Use Cases
Legacy Code Integration
Third-party Library Integration
Interface Incompatibility Resolution
API Wrapper Creation
Consequences and Trade-offs
Client-Adaptee Decoupling
Increased System Complexity
Performance Overhead
Maintenance Considerations
Best Practices and Guidelines
Decorator Pattern
Intent and Applicability
Problem Context
Solution Structure
Component Interface
ConcreteComponent Class
Decorator Abstract Class
ConcreteDecorator Classes
Implementation in Java
Composition-based Design
Java I/O Streams Example
Decorator Chaining
Common Use Cases
Dynamic Responsibility Addition
Subclass Explosion Avoidance
Feature Enhancement
Cross-cutting Concerns
Consequences and Trade-offs
Greater Flexibility than Inheritance
Small Object Proliferation
Complexity in Object Identity
Performance Considerations
Design Guidelines
Facade Pattern
Intent and Applicability
Problem Context
Solution Structure
Facade Class
Subsystem Classes
Implementation in Java
Subsystem Delegation
Interface Simplification
Error Handling Strategies
Common Use Cases
Complex Subsystem Simplification
Client-Subsystem Decoupling
Layered Architecture Implementation
API Simplification
Consequences and Trade-offs
Weak Coupling Promotion
God Object Risk
Limited Subsystem Access
Maintenance Benefits
Design Considerations
Composite Pattern
Intent and Applicability
Problem Context
Solution Structure
Component Interface
Leaf Class
Composite Class
Implementation in Java
Uniform Object Treatment
Tree Structure Management
Operation Propagation
Common Use Cases
Part-Whole Hierarchies
Tree Structure Representation
GUI Component Systems
File System Modeling
Consequences and Trade-offs
Simplified Client Code
Component Type Restriction Difficulty
Performance Implications
Memory Usage Considerations
Implementation Strategies
Proxy Pattern
Intent and Applicability
Problem Context
Solution Structure
Subject Interface
RealSubject Class
Proxy Class
Types of Proxies
Remote Proxy
Virtual Proxy
Protection Proxy
Smart Proxy
Cache Proxy
Implementation in Java
Static Proxy Implementation
Dynamic Proxy Usage
Reflection-based Proxies
Common Use Cases
Access Control Implementation
Lazy Initialization
Logging and Monitoring
Caching Mechanisms
Remote Object Access
Consequences and Trade-offs
Additional Indirection Layer
Performance Overhead
Transparency Benefits
Security Enhancement
Advanced Proxy Techniques
Bridge Pattern
Intent and Applicability
Problem Context
Solution Structure
Abstraction Class
RefinedAbstraction
Implementor Interface
ConcreteImplementor Classes
Implementation in Java
Abstraction-Implementation Composition
Interface Delegation
Hierarchy Separation
Common Use Cases
Interface-Implementation Decoupling
Platform Independence
Multiple Implementation Support
Runtime Implementation Switching
Consequences and Trade-offs
Improved Extensibility
Increased Complexity
Performance Considerations
Design Flexibility
Design Guidelines
Flyweight Pattern
Intent and Applicability
Problem Context
Solution Structure
Flyweight Interface
ConcreteFlyweight Class
UnsharedConcreteFlyweight Class
FlyweightFactory Class
State Management
Intrinsic State Characteristics
Extrinsic State Handling
State Separation Strategies
Implementation in Java
Object Pooling Techniques
Shared Object Caching
Factory Management
Common Use Cases
Large Object Collections
Memory Optimization
Character Rendering Systems
Game Object Management
Consequences and Trade-offs
Reduced Memory Usage
State Management Complexity
Performance Trade-offs
Thread Safety Considerations
Implementation Best Practices
Previous
2. Creational Patterns
Go to top
Next
4. Behavioral Patterns