S.O.L.I.D Flashcards

1
Q

[S]ingle Responsibility Principle

SRP

A

A class should have one, and only one, reason to change.

Cohesion is defined as the functional affinity of a Module’s element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

[O]pen/Closed Principle

OCP

A

You should be able to extend a classes behavior, without modifying it.

Note: Type classes were introduced first in Haskell as a new approach to ad-hoc polymorphism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

[L]iskov Substitution Principle

LSP

A

Derived classes must be replaceable for their base classes.

LSP is the enabling principle of the Open/Closed Principle

Despite Inheritance is a powerful mechanism, it must be used contextualized and moderating, avoiding cases of classes being extended only by having something in common.

Composition is easier to test , to maintain and less prone to errors

Traits concerns
Traits to model behaviors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

[I]nterface Segregation Principle

ISP

A

it’s better to have very specific interfaces than a general interface

Interfaces that have many Behaviors are difficult to maintain and evolve.

Make fine grained interfaces that are client specific

Cohesion in Interfaces

Interfaces = Behaviors

“fat” classes, can cause bizarre and damaging couplings to business rules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

[D]ependency Inversion Principle

DIP

A

Depend on abstractions, not on concretions.

“High-level modules should not depend on low-level modules. Both should depend on abstractions.”

“Abstractions should not depend on details. Details should depend on abstractions.”

Abstractions change less and make it easier to change behaviors and future code evolutions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

S.O.L.I.D

A

is an acronym that represents five principles of object-oriented programming and code design theorized by our beloved Uncle Bob

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Cohesion

A

Cohesion is defined as the functional affinity of a Module’s element.

It refers to the Relationship that the Members of this Module have if they have a more Direct and Important Relationship.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly