What is SOLID (object-oriented design)?
'''SOLID''' is a mnemonic [[acronym]] for a group of five good principles (rules) in [[computer programming]]. SOLID allows programmers to write code that is easier to understand and change later on. SOLID is often used with systems that use an [[object-oriented design]]. {{cn|date=November 2024}} SOLID was promoted by Robert C. Martin but the name itself was created by Michael Feathers. <ref>{{cite web |title=Uncle Bob Martin on Clean Software, Craftsperson, Origins of SOLID, DDD, & Software Ethics |url=https://www.infoq.com/podcasts/uncle-bob-solid-ddd/ |website=InfoQ |archiveurl=https://web.archive.org/web/20180824134615/https://www.infoq.com/podcasts/uncle-bob-solid-ddd/ |archivedate=24 August 2018 |language=en |date=24 August 2018}} </ref>{{better source|date=December 2024}} In essence, SOLID principles guide developers towards creating code that is more maintainable, flexible, and reusable. By adhering to these principles, one can build software systems that are easier to understand, modify, and extend over time. {{cn|date=November 2024}} == SOLID Principles== === Single responsibility principle (SRP) === Class has one job to do. Each change in requirements can be done by changing just one class.{{cn|date=November 2024}} ====Importance==== *Maintainability: When classes have a single, well-defined responsibility, they're easier to understand and modify.{{cn|date=November 2024}} *Testability: It's easier to write unit tests for classes with a single focus.{{cn|date=November 2024}} *Flexibility: Changes to one responsibility don't affect unrelated parts of the system.{{cn|date=November 2024}} === Open/closed principle (OCP) === Class is happy (open) to be used by others. Class is not happy (closed) to be changed by others.{{cn|date=November 2024}} ====Importance==== *Extensibility: New features can be added without modifying existing code.{{cn|date=November 2024}} *Stability: Reduces the risk of introducing bugs when making changes.{{cn|date=November 2024}} *Flexibility: Adapts to changing requirements