COURS 1 : SOLID Flashcards

1
Q

What are the Patterns, Principles

and Best practices of solid?

A
  • To deliver faster
  • To manage change
  • To manage complexity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the principles of Solid?

A
• A class needs to have a single responsibility
• GRASP PRINCIPLE :  High cohesion The methods of a class use a lot of the other members of the same class.
• GRASP PRINCPLE :Low coupling :The methods of a class do not use many members from other classes.
 High cohesion + Low coupling → Less responsibilities, less reasons to
change.
• So, maintain the cohesion and the coupling of the class!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do we mean when we say “Open-chest surgery isn’t needed when putting on a coat.”?

A
  • The software entities need to be open to extensions, but close to modifications.
  • Always think: “what will happen if the entity changes?”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define the Liskov principle.

A
  • The functions that use references to base classes must be able to use objects of the derived classes without knowing.
  • The preconditions cannot be enforced in the derived type. The derived methods cannot expect more than the base methods.
  • The postconditions cannot be more relaxed in the derived type. The derived methods cannot provide less than the base methods.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the interface segregation principle?

A

Multiple interfaces specific to clients are worth more than a single interface.

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

What is the dependency inverion principle?

A

• Depend on abstractions. Do not depend on concrete classes.
• The Holy Grail of software architecture!
• If we want to change the database, how many classes will we have to
change?
• If we depend on software libraries, our systems is locked within a
specific language (DIP violated).
• If we depend on REST APIs, our system remains independent of languages (DIP guaranteed).

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