Flashcards
(29 cards)
What is DRY principle in programming?
DRY stands for Don’t Repeat Yourself, a principle that promotes reducing repetition of code by extracting common pieces into reusable functions or components.
What does SOLID stand for in programming?
SOLID is an acronym for five design principles in object-oriented programming: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.
True or False: The Single Responsibility Principle states that a class should have only one reason to change.
True
What does KISS principle stand for in programming?
KISS stands for Keep It Simple, Stupid, a principle that encourages simplicity and avoiding unnecessary complexity in code.
What is the purpose of the Open-Closed Principle?
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.
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.
subclass
What does YAGNI stand for in programming?
YAGNI stands for You Aren’t Gonna Need It, a principle that advises against adding functionality until it is actually needed.
True or False: The Interface Segregation Principle states that clients should not be forced to depend on methods they do not use.
True
What is the Dependency Inversion Principle?
The Dependency Inversion Principle states that high-level modules should not depend on low-level modules, but both should depend on abstractions.
What is the purpose of the Composition Over Inheritance principle?
Composition Over Inheritance suggests favoring composition (has-a relationship) over inheritance (is-a relationship) to achieve greater flexibility and code reuse.
What is the Law of Demeter in programming?
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.
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.
False
What is the purpose of the Law of Least Astonishment in programming?
The Law of Least Astonishment aims to design systems in a way that minimizes surprises or unexpected behaviors, making code more intuitive and predictable.
What is the Rule of Three in programming?
The Rule of Three suggests that when a piece of code is duplicated twice, it should be refactored into a reusable function or component.
True or False: The Boy Scout Rule encourages leaving code cleaner than you found it by making small improvements whenever you work with it.
True
What is the Zero, One, Infinity rule in programming?
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.
What is the principle of Fail Fast in programming?
Fail Fast principle advocates for detecting and reporting errors as soon as they occur to prevent further damage and facilitate quicker debugging.
What does the Rule of Silence in programming recommend?
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.
What is the principle of Separation of Concerns in programming?
Separation of Concerns advocates dividing a program into distinct sections that address a separate concern, promoting modularity and maintainability.
What is the principle of Programming by Contract?
Programming by Contract involves defining precise specifications (preconditions, postconditions, and invariants) for functions or methods to ensure correct usage and behavior.
What is the principle of Convention Over Configuration?
Convention Over Configuration suggests using default conventions to reduce the need for explicit configuration, simplifying development and reducing boilerplate code.
What is the principle of Orthogonality in programming?
Orthogonality principle states that components or features should be independent of each other, allowing changes in one area without affecting others.
What is the principle of Least Privilege in programming?
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.
What is the principle of Immutability in programming?
Immutability principle suggests that objects or data structures should not be modified after creation, promoting simpler code, thread safety, and easier reasoning about state.