Clean Code Flashcards
What is the Law of Demeter?
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.
What is the purpose of encapsulation?
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.
What is a data transfer object (DTO)?
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.
What is the problem with exposing internal data through accessors?
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.
What is the Open/Closed principle?
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.
What is the “fail fast” principle?
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.
What are boundaries in software development?
Boundaries are the interfaces between different parts of a software system, such as between modules, layers, or components.
What is the purpose of boundaries?
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.
What are the risks of working with external code or systems?
Working with external code or systems can introduce several risks, including compatibility issues, versioning problems, security vulnerabilities, and performance bottlenecks.
What is a unit test?
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.
What is the “testing pyramid”?
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.
What is a class?
A class is a blueprint or template for creating objects, which encapsulates data and behavior into a single entity.
What is “concurrency”?
Concurrency is the ability of a system to execute multiple tasks or processes simultaneously or in parallel, without interfering with each other.
What is a “race condition”?
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.
What is “deadlock”?
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.