SOLID Principles - Kamills-12/2143-OOP GitHub Wiki

SOLID Principles

Kade Miller


What Is SOLID?

SOLID is a group of 5 design rules that help keep your object-oriented code clean and easy to change without breaking everything else.


Single Responsibility Principle

A class should only do one job.

If a class is handling user input, saving to a file, and doing math? It’s doing too much. Break it into smaller pieces.

Quick Example:

class FileLogger {
public:
    void log(string message) {
        cout << "[LOG]: " << message << endl;
    }
};

class Authenticator {
public:
    bool login(string username, string password) {
        // Logic here
        return true;
    }
};