SOLID हे पाच ऑब्जेक्ट-ओरिएंटेड डिজाइन तत्त्वांचा एक समूह आहे जो राखण्यायोग्य, लवचिक, समजण्यायोग्य कोड प्रोत्साहित करते: सिंगल रेस्पॉन्सिबिलिटी, ओपन/क्लोज्ड, लिस्कोव्ह सबस्टिट्यूशन, इंटरफेस सेग्रिगेशन आणि डिपेंडेंसी इनव्हर्जन. ते चांगल्या OO डिजाइनसाठी मार्गदर्शन करतात.
पाच तत्त्वे
S — SINGLE RESPONSIBILITY → a class should have ONE reason to change (one responsibility/job)
→ don't make classes do too much (avoid God objects)
O — OPEN/CLOSED → open for EXTENSION, closed for MODIFICATION → add new behavior without
changing existing code (e.g. via polymorphism/strategies)
L — LISKOV SUBSTITUTION → subtypes must be substitutable for their base types (a subclass
shouldn't break behavior expected of the parent)
I — INTERFACE SEGREGATION → many specific interfaces > one fat interface → clients shouldn't
depend on methods they don't use
D — DEPENDENCY INVERSION → depend on ABSTRACTIONS, not concrete implementations → high-level
modules don't depend on low-level details (relates to DI)
