Factory pattern వాటి ఖచ్చితమైన class నిర్దేశించకుండానే objects సృష్టించడానికి ఒక మార్గాన్ని అందిస్తుంది — ఒక method లేదా class object సృష్టిని నిర్వహిస్తుంది, ఏ type ను instantiate చేయాలో నిర్ణయిస్తుంది. ఇది object సృష్టిని కేంద్రీకృతం చేస్తుంది మరియు సంగ్రహం చేస్తుంది, కోడ్ను concrete classes నుండి విడదీస్తుంది.
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
