Clean Code Flashcards

1
Q

What is the Law of Demeter?

A

The Law of Demeter (LoD) is a design guideline that recommends that objects should only talk to their immediate neighbors, i.e., objects that they directly interact with.

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

What is the purpose of encapsulation?

A

Encapsulation is the practice of hiding the internal details of an object from the outside world, to improve the maintainability, scalability, and security of the code.

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

What is a data transfer object (DTO)?

A

A data transfer object (DTO) is a data structure that is used to transfer data between layers or modules of an application, without exposing the internal details of the objects being transferred.

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

What is the problem with exposing internal data through accessors?

A

Exposing internal data through accessors (getters and setters) breaks encapsulation, because it allows external code to manipulate the internal state of an object directly, without going through its methods.

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

What is the Open/Closed principle?

A

The Open/Closed principle is a design guideline that states that classes should be open for extension but closed for modification, i.e., new behavior should be added by creating new classes, rather than modifying existing ones.

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

What is the “fail fast” principle?

A

The “fail fast” principle is a design guideline that recommends that errors should be detected and handled as early as possible, to prevent them from propagating and causing more damage later on.

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

What are boundaries in software development?

A

Boundaries are the interfaces between different parts of a software system, such as between modules, layers, or components.

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

What is the purpose of boundaries?

A

The purpose of boundaries is to manage the complexity of a software system, by isolating different parts of the system from each other, and by providing clear and consistent interfaces between them.

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

What are the risks of working with external code or systems?

A

Working with external code or systems can introduce several risks, including compatibility issues, versioning problems, security vulnerabilities, and performance bottlenecks.

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

What is a unit test?

A

A unit test is a type of automated test that verifies the behavior of a small, isolated unit of code, such as a function or method.

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

What is the “testing pyramid”?

A

The testing pyramid is a model that suggests that a software system should have a large number of unit tests, a smaller number of integration tests, and an even smaller number of end-to-end tests. This model helps to ensure that the system is thoroughly tested at all levels, while keeping the test suite manageable and maintainable.

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

What is a class?

A

A class is a blueprint or template for creating objects, which encapsulates data and behavior into a single entity.

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

What is “concurrency”?

A

Concurrency is the ability of a system to execute multiple tasks or processes simultaneously or in parallel, without interfering with each other.

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

What is a “race condition”?

A

A race condition is a type of concurrency issue that occurs when two or more processes or threads try to access and modify a shared resource or data at the same time, leading to unexpected and incorrect behavior.

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

What is “deadlock”?

A

Deadlock is a type of concurrency issue that occurs when two or more processes or threads are blocked or waiting for each other to release a resource or a lock, leading to a situation where none of the processes or threads can proceed.

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

What is “livelock”?

A

Livelock is a type of concurrency issue that occurs when two or more processes or threads are continuously changing their state or behavior in response to each other, without making any progress or achieving their goals.

17
Q

What is “starvation”?

A

Starvation is a type of concurrency issue that occurs when one or more processes or threads are continuously blocked or waiting for a resource or a lock, leading to a situation where they cannot proceed or make progress.

18
Q

What is a “distributed system”?

A

A distributed system is a type of system that consists of multiple nodes or components that are geographically distributed and communicate with each other over a network.

19
Q

What is “continuous integration” (CI)?

A

Continuous integration is a development practice that involves regularly and automatically building and testing the code, to ensure that it remains functional and reliable, and to catch any issues or defects early.

20
Q

What is “concurrency”?

A

Concurrency is the ability of a system to execute multiple tasks or processes simultaneously or in parallel, without interfering with each other.

21
Q

What is a “thread”?

A

A thread is a sequence of instructions that can be executed independently by a computer processor. In software development, threads are used to allow multiple tasks or processes to run concurrently within the same program or application.

22
Q

What is “synchronization”?

A

Synchronization is the process of coordinating and controlling access to shared resources or data, to ensure that only one thread can access them at a time, and to prevent race conditions.

23
Q

What is a “mutex”?

A

A mutex is a synchronization object that can be used to enforce mutual exclusion, by allowing only one thread to access a shared resource or data at a time.

24
Q

What is a “thread pool”?

A

A thread pool is a collection of threads that are created in advance and reused multiple times to perform tasks.

25
Q

What is a “monitor”?

A

A monitor is a synchronization mechanism that can be used to ensure mutual exclusion and coordination between threads, by providing a set of synchronized methods and conditions.

26
Q

What is “lock-free programming”?

A

Lock-free programming is a programming approach that avoids the use of locks and synchronization primitives, and instead relies on atomic operations and other techniques to ensure concurrency and consistency.

27
Q

What is an atomic operation?

A

An atomic operation is a single action that is guaranteed to complete entirely or not at all. It’s commonly used in multi-threaded programming to ensure data consistency and prevent race conditions.