Clean Code Principles

Best practices for writing maintainable, readable, and efficient code with practical examples

Category
Programming
Level
intermediate
Languages
en → en
Cards
47
Markdown
Clean Code Principles (.md)

Flashcards (47)

#Front (Term / Question)Back (Definition / Answer)ExampleMultiple-Choice Options
1How does 'refactoring' contribute to Clean Code?Refactoring improves the structure of existing code without changing its external behavior, enhancing readability and maintainability.
2What is the 'principle of least privilege'?The principle of least privilege states that users and systems should have the minimum level of access necessary to perform their functions.
3What is 'code documentation'?Code documentation provides explanations and context for code, helping other developers understand its purpose and usage.
4What does 'agile methodology' emphasize?Agile methodology emphasizes flexibility, collaboration, and customer feedback, allowing for rapid iteration and improvement of software.
5What is the 'Liskov Substitution Principle'?The Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program.
6What does 'agile development' contribute to Clean Code?Agile development promotes iterative progress and flexibility, encouraging frequent refactoring and adaptation to changing requirements.
7What does 'meaningful names' refer to in Clean Code?Meaningful names refer to using descriptive and unambiguous names for variables, functions, and classes to convey their purpose clearly.
8What is the importance of comments in Clean Code?Comments should explain 'why' something is done, not 'what' is done; well-written code should be self-explanatory, minimizing the need for comments.
9What does 'composition over inheritance' mean?Composition over inheritance is a design principle that favors composing objects with desired behaviors rather than inheriting from a base class.
10What is 'static code analysis'?Static code analysis is the examination of code without executing it, identifying potential errors, vulnerabilities, and adherence to coding standards.
11What does 'test coverage' refer to?Test coverage refers to the percentage of code that is tested by automated tests, indicating the extent to which the codebase is validated.
12Why is consistent formatting important in Clean Code?Consistent formatting improves readability and makes it easier for developers to navigate and understand the codebase.
13What is 'agile retrospectives'?Agile retrospectives are meetings held at the end of an iteration to reflect on what went well, what didn't, and how to improve in the next cycle.
14What is the 'KISS' principle?KISS stands for 'Keep It Simple, Stupid.' It emphasizes simplicity in design and implementation to avoid unnecessary complexity.
15What is 'agile testing'?Agile testing is a practice that integrates testing into the development process, ensuring that quality is maintained throughout the software lifecycle.
16What is the significance of 'user feedback' in Clean Code?User feedback provides insights into how well the code meets user needs, guiding improvements and ensuring the software is user-friendly.
17Why is it important to handle errors gracefully?Graceful error handling improves user experience and system reliability by preventing crashes and providing meaningful feedback.
18What is 'agile planning'?Agile planning involves defining the scope and objectives of a project in a flexible manner, allowing for adjustments based on ongoing feedback and changes.
19What is 'separation of concerns'?Separation of concerns is a design principle that divides a program into distinct sections, each addressing a separate concern, improving modularity.
20What does 'modular design' entail?Modular design involves breaking down a program into smaller, self-contained modules that can be developed, tested, and maintained independently.
21What does 'behavior-driven development' (BDD) involve?BDD involves writing tests in a natural language format that describes the behavior of the application, facilitating collaboration between developers and non-technical stakeholders.
22How can 'pair programming' enhance Clean Code practices?Pair programming encourages collaboration and immediate feedback, leading to higher quality code and shared knowledge among team members.
23What is the significance of 'version control' in Clean Code?Version control tracks changes to code, allowing for collaboration, history tracking, and easy rollback to previous versions if needed.
24Why is it important to keep functions small?Small functions are easier to understand, test, and reuse, promoting better readability and maintainability.
25What is the primary goal of Clean Code principles?The primary goal of Clean Code principles is to write code that is easy to read, understand, and maintain.
26What is the 'principle of least astonishment'?The principle of least astonishment states that code should behave in a way that least surprises the user, making it intuitive and predictable.
27What is 'agile coaching'?Agile coaching involves guiding teams in adopting agile practices, improving their processes, and fostering a culture of continuous improvement.
28What is 'continuous integration'?Continuous integration is a practice where developers frequently integrate code changes into a shared repository, allowing for early detection of issues.
29What is the 'YAGNI' principle?YAGNI stands for 'You Aren't Gonna Need It.' It advises against adding functionality until it is necessary to avoid overcomplicating the code.
30What is meant by 'code smells'?Code smells are indicators of potential problems in code, such as duplicated code, long methods, or excessive parameters, suggesting that refactoring may be needed.
31What does 'DRY' stand for and why is it important?DRY stands for 'Don't Repeat Yourself.' It is important because it reduces redundancy, minimizes errors, and makes code easier to maintain.
32What is 'pair testing'?Pair testing involves two testers working together to test a feature, combining their perspectives to identify issues more effectively.
33What is 'code review' and its significance?Code review is the process of evaluating code changes by peers, which helps identify issues, improve code quality, and share best practices.
34What is the 'Open/Closed Principle'?The Open/Closed Principle states that software entities should be open for extension but closed for modification, allowing for new functionality without altering existing code.
35What is the 'Dependency Inversion Principle'?The Dependency Inversion Principle states that high-level modules should not depend on low-level modules; both should depend on abstractions.
36What is the role of 'design patterns' in Clean Code?Design patterns provide proven solutions to common problems, promoting code reuse and improving code organization.
37What is the importance of 'user stories' in Clean Code?User stories help define requirements from the user's perspective, ensuring that the code developed meets actual user needs.
38What does 'agile backlog' mean?An agile backlog is a prioritized list of tasks, features, and requirements that need to be completed in a project, guiding development efforts.
39What does 'encapsulation' mean in the context of Clean Code?Encapsulation is the practice of restricting access to certain components of an object, promoting modularity and reducing dependencies.
40What is the 'Single Responsibility Principle'?The Single Responsibility Principle states that a class should have only one reason to change, meaning it should only have one job or responsibility.
41What does 'cross-functional teams' mean?Cross-functional teams consist of members with different expertise working together towards a common goal, enhancing collaboration and innovation.
42What is 'technical debt'?Technical debt refers to the implied cost of additional rework caused by choosing an easy solution now instead of a better approach that would take longer.
43What is the role of 'unit tests' in Clean Code?Unit tests verify that individual components of the code work as intended, ensuring reliability and facilitating future changes.
44What is 'user acceptance testing' (UAT)?User acceptance testing is the final phase of testing where actual users validate the software against their requirements before it goes live.
45What is 'code maintainability'?Code maintainability refers to how easily code can be modified, updated, or extended over time without introducing errors.
46What does 'code simplicity' mean?Code simplicity refers to writing code that is straightforward and easy to understand, avoiding unnecessary complexity.
47What does 'test-driven development' (TDD) involve?TDD involves writing tests before writing the corresponding code, ensuring that the code meets requirements and is less prone to bugs.