Skip to content

Instantly share code, notes, and snippets.

@byJeevan
Created July 14, 2026 12:38
Show Gist options
  • Select an option

  • Save byJeevan/cb021c45bf0ebd04ddd1325c88e5d110 to your computer and use it in GitHub Desktop.

Select an option

Save byJeevan/cb021c45bf0ebd04ddd1325c88e5d110 to your computer and use it in GitHub Desktop.
Architecture and Design System QnA

Architecture and Design System related QnA

@byJeevan

Copy link
Copy Markdown
Author

SOLID Principle

The SOLID principles are 5 design principles used to write clean, maintainable, and scalable code.

  1. S — Single Responsibility Principle (SRP)
    A class should have only one reason to change.
    → One class = one responsibility.

  2. O — Open/Closed Principle (OCP)
    Code should be open for extension but closed for modification.
    → Add new behavior without changing existing code.

  3. L — Liskov Substitution Principle (LSP)
    Subclasses should be replaceable for their parent classes without breaking behavior.
    → Child class must behave correctly as parent.

  4. I — Interface Segregation Principle (ISP)
    Don’t force classes to implement methods they don’t need.
    → Create small, specific interfaces.

  5. D — Dependency Inversion Principle (DIP)
    Depend on abstractions, not concrete implementations.
    → Use protocols/interfaces instead of direct class dependency.

Simple iOS Example

Instead of:

class NetworkManager {
    func fetch() {}
}

Prefer:

protocol Networking {
    func fetch()
}

class NetworkManager: Networking {
    func fetch() {}
}

class HomeViewModel {
    let network: Networking
    init(network: Networking) {
        self.network = network
    }
}

This follows DIP and improves testing & flexibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment