Overview
Category
Creational Design Pattern
Purpose
Encapsulate object creation logic
Problem Statement
The Challenge
The Challenge
We need to create different classifier and strategy objects based on runtime configuration:
- Encapsulate creation logic: Complex initialization
- OCP Compliance: Add new types without modifying factory code
- Centralized creation: Single point of change
OCP Demonstration
OCP Demonstration
Adding a new classifier requires ONLY:✅ Open for extension, closed for modification
Solution: Dictionary Map Factory
- Flowchart
- Classifier Factory
- Strategy Factory
- File Locations
Benefits
OCP Compliance
Add new types by adding to registry only
Encapsulation
Complex creation logic hidden from client
Centralized
Single point of change for object creation
Configurable
Runtime selection via environment variables