Factory pattern ऑब्जेक्ट्स तयार करण्याचा एक मार्ग प्रदान करते त्यांची अचूक क्लास निर्दिष्ट न करता — एक पद्धति किंवा क्लास जी ऑब्जेक्ट निर्माण हाताळते, कोणता प्रकार त्वरित केला जाईल हे ठरवते. हे ऑब्जेक्ट निर्माण केंद्रीभूत करते आणि अमूर्त करते, कोडला काँक्रिट क्लासेस पासून विखुरलेले करते.
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
