Skip to content

Instantly share code, notes, and snippets.

View cbedoy's full-sized avatar

Bedoy cbedoy

View GitHub Profile
@dandvl
dandvl / SOLID.md
Last active December 30, 2020 19:29

Single Responsibility Principle (SRP)

A Class shouldn't have more than one Responsibility
Violation - when the POJO class saves into the database and generates reports)

Open Closed Principle (OCP)

Open for extension, Closed for modification. Every time we add sibling classes, we shouldn't modify the existing methods that are working with them.
Violation - switch statements in the methods to call different behaviors for each sibling class, instead of using polymorphism

Liskov Substitution Principle (LSP)

Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program. Violation - when you pass a subclass to a method and obtain a different result when you pass the class

Interface Segregation Principle (ISP)