SOLID principles Flashcards

1
Q

Symptoms of bad software

A

Confusing

Rigidity: To make a modification you need to touch a lot of stuff.

Fragility: You change something somewhere, and it breaks the software in unexpected areas that are entirely unrelated to the change you made.

Immobility (no-reusability): The software does more than what you need. The desirable parts of the code are so tightly coupled to the undesirable ones that you cannot you use the desirable parts somewhere else.

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

What makes a language OO?

A

Encapsulation
Inheritance
Polymorphism

Encapsulation: Bundling data and methods into a class while controlling access.

Inheritance: Subclass inheriting properties and behaviors from a superclass.

Polymorphism: Treating objects of different types as if they are of a common type.

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

Coupling

A

The degree of interdependence between software modules or components. It measure how closely one module is connected to, or relies on, another.

We want low coupling.

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

Cohesion

A

The degree to which the functionality within a module is related and focused on a single, well defined purpose.

High cohesion means that a module or
class is designed to perform a
specific, clear task, and it doesn’t
contain unrelated or loosely
related functionality.

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

Name all five principles of SOLID

A

Single responsible principle
Open / closed principle
Liskov substitution principle
Interface segregation principle
Dependency Inversion Principle

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

Single responsible principle

A

“a class should only have one, and only one, reason to change”

Only one reason to change and should only have one responsibility.

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

Open / closed principle

A

“software entities should be open for extensions but closed
for modifications”

You should not have to rewrite an existing class for implementing new features.

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

Liskov substitution principle

A

“derived classes should be usable through the base class interface, without the need for the user to know the difference”

Subtypes should be substitutable for their base types without altering the correctness of the program.

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

Interface segregation principle

A

“many client-specific interfaces are better than one general-purpose interface”

i.e. if you have transaction, split into deposit transaction, withdrawal transaction and transfer transaction.

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

Dependency-inversion principle

A

“depend upon abstractions, do not depend upon concretions”

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