SOLID is a set of five design principles for object-oriented code, popularised by Robert C. Martin. Each one targets the same problem: code that gets harder to change every time you touch it.
The five principles
Single responsibility
A class should have one reason to change. A class that formats invoices, saves them to a database and emails them has three, so a change to the email template risks breaking the database code. Split it into pieces that each do one job.
Open/closed
Code should be open for extension but closed for modification. When a new case arrives, such as a new payment method, you should be able to add a new class rather than edit a long if/else chain that already works and is already tested.
Liskov substitution
Named after Barbara Liskov, this says a subclass must work anywhere its parent class is expected. If code that handles a Bird breaks when given a Penguin because fly() throws an error, the fault is in the hierarchy: the subclass has broken a promise its parent made.
Interface segregation
No class should be forced to depend on methods it doesn't use. Several small, focused interfaces beat one large one: a printer class shouldn't have to implement scan() and fax() just to satisfy a shared interface.
Dependency inversion
High-level code should depend on abstractions, not on concrete details. Business logic shouldn't create its own database connection or email client; it should ask for something that fulfils a contract and let the caller pass in the real thing.
Wondering how this was made? How we make these