Skip to content

A collection of essential programming questions for self-assessment and code quality improvement. Contribute your answers and engage in discussions to enhance your programming skills

Notifications You must be signed in to change notification settings

etg-dev/Clean_Code_QA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Important Questions Every Programmer Should Ask Themselves

Welcome to the repository containing a collection of important questions that every programmer should ask themselves. These questions cover various aspects of software development, coding practices, and clean code principles. They can serve as a valuable self-assessment tool to improve your coding skills and promote better software development practices.

Introduction

As a programmer, it's crucial to continuously evaluate your coding practices and strive for improvement. This collection of questions is designed to encourage self-reflection and help you enhance your understanding of clean code principles. By asking yourself these questions, you can identify areas for improvement and cultivate better coding habits.


Questions

Q1. What is the importance of writing clean code?

Q2. How can you ensure that your code is readable and understandable?

Q3. What is the significance of writing self-explanatory code?

Q4. What is the purpose of code formatting and indentation?

Q5. What is the purpose of code comments?

Q6. What is the purpose of the "Boy Scout Rule"?

Q7. What are the SOLID principles of object-oriented design?

Q8. How does the Single Responsibility Principle (SRP) contribute to clean code?

Q9. Explain the Open-Closed Principle (OCP) and its benefits

Q10. How can you handle error conditions and exceptions in your code?

Q11. How can you effectively name variables, functions, and classes?

Q12. Which of the following is NOT a principle of clean code?

Q13. Which of the following is a benefit of writing clean code?

Q14. Which of the following is an important practice for writing clean code?

Q15. Which of the following is an example of a code smell?

Q16. Which of the following is NOT an aspect of clean code?

Q17. Which of the following is a principle of the SOLID design principles?

Q18. Which of the following is NOT a best practice for writing clean code?

Q19. Which of the following is an example of a code refactoring technique?

Q20. Which of the following is an important aspect of writing clean code in a team environment?

Q21. Which of the following is a benefit of using automated testing in clean code development?

Q22. which of the following is NOT considered as good comments?

Q23. choose the incorrect option?

Q24. choose the correct answer about clean code?

Q25. which of the following names can be set for a function, a boolean and a variable by order?

Q26. we want to save some user login data with functions in our app but before that we want to validate the data. what's the best option?


Q1. What is the importance of writing clean code?

  • It makes the code faster.
  • It improves code readability and maintainability.
  • It eliminates the need for testing.
  • It reduces the size of the codebase.

Q2. How can you ensure that your code is readable and understandable?

  • By using complex algorithms and data structures.
  • By minimizing comments to keep the code concise.
  • By following naming conventions and using descriptive names.
  • By avoiding any form of code refactoring.

Q3. What is the significance of writing self-explanatory code?

  • It saves time during code reviews.
  • It eliminates the need for unit testing.
  • It improves code performance.
  • It reduces the cognitive load on developers.

Q4. What is the purpose of code formatting and indentation?

  • It is purely a matter of personal preference
  • It reduces the file size of the code.
  • It improves code readability and understanding.
  • It ensures code compatibility with different programming languages.

Q5. What is the purpose of code comments?

  • To make the code more confusing.
  • To explain every line of code in detail.
  • To provide additional information that is not evident from the code itself.
  • To replace the need for writing self-explanatory code.

Q6. What is the purpose of the "Boy Scout Rule"?

  • Always leave the code worse than you found it.
  • Refactor the code only if it is completely broken.
  • T Improve the code a little bit whenever you touch it.
  • Avoid making any changes to the existing codebase.

Q7. What are the SOLID principles of object-oriented design?

  • Simple, Optimized, Logical, Integrated, Dynamic.
  • Structured, Organized, Layered, Independent, Decoupled.
  • Single, Open, Liskov, Interface, Dependency.
  • Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.

Q8. How does the Single Responsibility Principle (SRP) contribute to clean code?

  • It ensures that a class has only one method.
  • It limits the number of lines of code in a module.
  • It restricts the use of inheritance in object-oriented design.
  • It ensures that a class has only one reason to change.

Q9. Explain the Open-Closed Principle (OCP) and its benefits

  • It states that software entities should be open for modification and closed for extension.
  • It promotes the use of global variables for easy code maintenance.
  • It suggests that code should be rewritten from scratch for each new requirement.
  • It encourages tightly-coupled modules to achieve better performance.

Q10. How can you handle error conditions and exceptions in your code?

  • Ignore the errors and hope they won't occur.
  • Use global error handlers to catch all exceptions.
  • Handle errors locally and provide meaningful error messages.
  • Avoid using exception handling altogether.

Q11. How can you effectively name variables, functions, and classes?

  • Use short and cryptic names to save memory.
  • Avoid using naming conventions to keep the code concise.
  • Use slang names to keep code user friendly.
  • Use short name with descriptive comment.

Q12. Which of the following is NOT a principle of clean code?

  • Keep it simple.
  • Minimize the number of comments.
  • Name things clearly.
  • Write tests.

Q13. Which of the following is a benefit of writing clean code?

  • It makes debugging faster and easier.
  • It increases development time.
  • It increases the number of bugs.
  • It makes code less readable.

Q14. Which of the following is an important practice for writing clean code?

  • Using descriptive variable names.
  • Overusing global variables.
  • Avoiding testing code.
  • Hardcoding values into the code.

Q15. Which of the following is an example of a code smell?

  • A function with a single responsibility.
  • Comments explaining what the code does.
  • Duplication of code in multiple places.
  • Short and concise function names.

Q16. Which of the following is NOT an aspect of clean code?

  • Consistency.
  • Simplicity.
  • Speed.
  • Clarity.

Q17. Which of the following is a principle of the SOLID design principles?

  • Separation of concerns.
  • Avoiding unit tests.
  • Hardcoding values.
  • Using global variables.

Q18. Which of the following is NOT a best practice for writing clean code?

  • Use long and complex function names.
  • Keep functions small and focused.
  • Avoid using nested code blocks.
  • Use consistent formatting.

Q19. Which of the following is an example of a code refactoring technique?

  • Adding more comments to the code.
  • Removing redundant code.
  • Using shorter variable names.
  • Hardcoding values into the code.

Q20. Which of the following is an important aspect of writing clean code in a team environment?

  • Consistent formatting.
  • Using global variables.
  • Avoiding testing code.
  • Writing long and complex functions.

Q21. Which of the following is a benefit of using automated testing in clean code development?

  • It increases the number of bugs.
  • It makes debugging more difficult.
  • It improves code quality.
  • It slows down development time.

Q22. which of the following is NOT considered as good comments?

  • legal information
  • explainig variables and functions
  • warnings
  • todos

Q23. choose the incorrect option?

  • a clean function doesn't have more than 3 parameters at all.
  • clean functions should be small and do only one thing
  • using dictionaries rather than 2 parameters can make a function cleaner
  • a function with 2 parameters is OK

Q24. choose the correct answer about clean code?

  • there are some special rules that you must follow all of them, so that your code is considered as clean code
  • writing clean code takes too much time
  • it's all about writing a readable, understandable and maintainable code
  • none of above is correct

Q25. which of the following names can be set for a function, a boolean and a variable by order?

  • loginData, isLoggedIn, checkLogin
  • checkLogin, isLoggedIn, loginData
  • loginData, checkLogin, isLoggedIn
  • checkLogin, loginData, isLoggedIn

Q26. we want to save some user login data with functions in our app but before that we want to validate the data. what's the best option?

  • we can write a save function to first validate data and if they're valid, save data
  • we can name the function validateAndSave and do the above option
  • we can write functions for each of validaing and saving specifically
  • none of them

About

A collection of essential programming questions for self-assessment and code quality improvement. Contribute your answers and engage in discussions to enhance your programming skills

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published