In the last episode of knowledge ketchup at Gurzu, Kiran explored the SOLID principles - five foundational guidelines for writing maintainable and scalable object-oriented code.
becomes hard to maintain or improve. • Hidden Bugs & Undefined Behavior • Security Vulnerabilities • Bug Becomes a Feature • Lack of Test/ Poor Coverage To solve this issue SOLID is one of them. Problem Statements without using proper patterns
Open/Closed 🎯 L — Liskov Substitution 🎯 I — Interface Segregation 🎯 D — Dependency Inversion 📖 A design principle set for building clean, scalable, testable software. What is SOLID?
force clients to depend on unused methods.” Bad: abstract class Worker { void work(); void eat(); // ❌ Not all workers need this } class Robot implements Worker { @override void eat() => throw Error(); // ❌ Forced to implement } Good: abstract class Workable { void work(); } // ✅ Split interfaces abstract class Eatable { void eat(); } class Human implements Workable, Eatable { ... } class Robot implements Workable { ... }
abstractions not concreations” Bad: class UserService { final FirebaseAuth _auth = FirebaseAuth(); // ❌ Hard dependency } Good: class UserService { final AuthInterface _auth; // ✅ Depends on abstraction UserService(this._auth); }