Factory pattern என்பது object களை அவற்றின் exact class ஐ specify செய்யாமல் create செய்வதற்கான ஒரு வழி — object creation ஐ handle செய்யும் ஒரு method அல்லது class, எந்த type ஐ instantiate செய்வது என்பதை தீர்மானிக்கும். இது object creation ஐ centralize செய்து abstract பண்ணுகிறது, code ஐ concrete classes இல் இருந்து decouple செய்கிறது.
Factory pattern என்ன செய்கிறது
FACTORY → encapsulate object CREATION (instead of calling constructors directly):
→ a factory method/class decides WHICH class to instantiate and creates it
→ the caller asks the factory for an object (by type/parameter) → gets the right object
WITHOUT knowing/specifying the concrete class
→ decouples code from CONCRETE classes; centralizes creation logic
