Factory Design Pattern
Learn Factory Design Pattern (Creational Patterns, Design Patterns in Java) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Factory Design Pattern is used to create objects without exposing object creation logic to the client. Simple Meaning: Instead of using new keyword everywhere, we create objects using a Factory class . Why Factory Pattern? Removes tight coupling Centralizes object creation Makes code cleaner Basic Structure: Step 1: Create Interface Step 2: Create Concrete Classes Step 3: Create Factory Class Step 4: Call Factory from Client Real Life Example: Shape Factory → Circle, Rectangle, Square