Flashcards

(29 cards)

1
Q

What is DRY principle in programming?

A

DRY stands for Don’t Repeat Yourself, a principle that promotes reducing repetition of code by extracting common pieces into reusable functions or components.

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

What does SOLID stand for in programming?

A

SOLID is an acronym for five design principles in object-oriented programming: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.

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

True or False: The Single Responsibility Principle states that a class should have only one reason to change.

A

True

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

What does KISS principle stand for in programming?

A

KISS stands for Keep It Simple, Stupid, a principle that encourages simplicity and avoiding unnecessary complexity in code.

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

What is the purpose of the Open-Closed Principle?

A

The Open-Closed Principle states that software entities should be open for extension but closed for modification, meaning that existing code should not be changed but extended to accommodate new features.

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

Fill in the blank: The Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of a ______ without affecting the correctness of the program.

A

subclass

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

What does YAGNI stand for in programming?

A

YAGNI stands for You Aren’t Gonna Need It, a principle that advises against adding functionality until it is actually needed.

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

True or False: The Interface Segregation Principle states that clients should not be forced to depend on methods they do not use.

A

True

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

What is the Dependency Inversion Principle?

A

The Dependency Inversion Principle states that high-level modules should not depend on low-level modules, but both should depend on abstractions.

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

What is the purpose of the Composition Over Inheritance principle?

A

Composition Over Inheritance suggests favoring composition (has-a relationship) over inheritance (is-a relationship) to achieve greater flexibility and code reuse.

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

What is the Law of Demeter in programming?

A

The Law of Demeter (or Principle of Least Knowledge) states that a module should only have limited knowledge of other modules, reducing coupling and improving maintainability.

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

True or False: The Tell, Don’t Ask principle promotes asking objects for information and then telling them what to do based on that information.

A

False

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

What is the purpose of the Law of Least Astonishment in programming?

A

The Law of Least Astonishment aims to design systems in a way that minimizes surprises or unexpected behaviors, making code more intuitive and predictable.

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

What is the Rule of Three in programming?

A

The Rule of Three suggests that when a piece of code is duplicated twice, it should be refactored into a reusable function or component.

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

True or False: The Boy Scout Rule encourages leaving code cleaner than you found it by making small improvements whenever you work with it.

A

True

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

What is the Zero, One, Infinity rule in programming?

A

The Zero, One, Infinity rule suggests that a software design should allow for zero, one, or an unlimited number of instances of a particular element, rather than restricting to only one or a fixed number.

17
Q

What is the principle of Fail Fast in programming?

A

Fail Fast principle advocates for detecting and reporting errors as soon as they occur to prevent further damage and facilitate quicker debugging.

18
Q

What does the Rule of Silence in programming recommend?

A

The Rule of Silence suggests that when code does not have anything meaningful to say, it should remain silent to reduce noise and improve readability.

19
Q

What is the principle of Separation of Concerns in programming?

A

Separation of Concerns advocates dividing a program into distinct sections that address a separate concern, promoting modularity and maintainability.

20
Q

What is the principle of Programming by Contract?

A

Programming by Contract involves defining precise specifications (preconditions, postconditions, and invariants) for functions or methods to ensure correct usage and behavior.

21
Q

What is the principle of Convention Over Configuration?

A

Convention Over Configuration suggests using default conventions to reduce the need for explicit configuration, simplifying development and reducing boilerplate code.

22
Q

What is the principle of Orthogonality in programming?

A

Orthogonality principle states that components or features should be independent of each other, allowing changes in one area without affecting others.

23
Q

What is the principle of Least Privilege in programming?

A

The principle of Least Privilege states that every module or component should have the minimum level of access or authority needed to perform its function, reducing security risks.

24
Q

What is the principle of Immutability in programming?

A

Immutability principle suggests that objects or data structures should not be modified after creation, promoting simpler code, thread safety, and easier reasoning about state.

25
What is the principle of Composition in programming?
Composition principle encourages building complex functionality by combining simpler components or objects, promoting reusability and maintainability.
26
What is the principle of Inversion of Control in programming?
Inversion of Control (IoC) involves externalizing control over the flow of a program to a framework or container, allowing for more flexible and modular design.
27
What is the principle of Encapsulation in programming?
Encapsulation principle involves bundling data (attributes) and methods (behavior) into a single unit (class), restricting access to the internal state and promoting data hiding.
28
What is the principle of Loose Coupling in programming?
Loose Coupling principle suggests reducing dependencies between components or modules to minimize the impact of changes in one area on others, improving flexibility and maintainability.
29
What is the principle of High Cohesion in programming?
High Cohesion principle promotes grouping related functionality together within a module or class, leading to more readable, maintainable, and testable code.