# SOLID Principles

> Five rules for building classes. They keep code easy to change.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** SOLID, SOLID Design Principles, Single Responsibility Principle, Open-Closed Principle

## Think of it like

Think of it like five rules for toy bricks. You can swap one brick and the tower stays up.

## Definition

SOLID is five rules for designing classes in object-oriented code so they are easy to change. S: each class has one job. O: you can add behaviour without editing old code. L: a child class must work anywhere its parent does. I: keep interfaces small. D: depend on interfaces, not on concrete classes.

## Example

Emma's Report class makes reports and also emails them. Following the first SOLID rule, she splits it in two. Now changing the email code cannot break the reports.

## Why it matters

As code grows, changes start to break things far away. SOLID keeps parts apart, so a change stays local.

## Common mistake

Applying all five rules to a tiny script. They help large, long-lived code; in small code they just add layers.

## Three principles

- **One job per class.** The S.
- **Add, do not edit.** The O.
- **Lean on interfaces.** The I and the D.

## Related terms

- [Object-Oriented Programming (OOP)](https://learn.benibix.com/term/development/object-oriented-programming)
- [Class](https://learn.benibix.com/term/development/class)
- [Interface (Programming)](https://learn.benibix.com/term/development/interface)
- [Inheritance](https://learn.benibix.com/term/development/inheritance)

## Taught in

- [DRY, KISS and YAGNI](https://learn.benibix.com/learn/development-concepts/dry-kiss-and-yagni): Programming Basics, 18/18

---

Source: https://learn.benibix.com/term/development/solid-principles
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
