Today I Learned - Rocky Kev

TIL when to use SOLID in 2021

POSTED ON:

TAGS:

What is SOLID?
SOLID is an acronym for 5 principles

S. 👉 Single Responsibility

O. 👉 Open/Close

L. 👉 Liskov Substitution

I. 👉 Interface Segregation

D. 👉 Dependency Inversion

Use Avoid
Single Responsibility For Scalable and Maintainable Code. When too much Fragmentation occurs without predictable future changes.
Open Close To prevent old code from breaking due to a new one. When over-engineering.
Liskov Substitution Parent/Child used interchangeably without breaking. When substitutions do not make sense. (Bird example)
Interface Segregation For Role-specific interfaces. When difficult to aggregate (due to a lot of modules) from segregation.
Dependency Inversion For different low-level implementations. When different implementations of a low-level module are not needed, like the String class in most languages are not changed because it's not needed to mostly.

REFERENCE:

Solid. Is It Still Useful In 2021?


Related TILs

Tagged:

TIL Indirection and Swallowing the error

Op shared a tryCatch util that is problematic.

TIL reusing variables

Do not reuse variables. Do not double define variables that represent the same thing.

TIL about semaphores

A semaphore limits access to a resource to some number of consumers. Any new requests for the resource will get stalled until later, eventually to be handled.