CLEAN CODE TIPS | SOFTWARE DEVELOPMENT CODE REVIEW BEST PRACTICES | TIPS CLEAN CODE | InterviewDOT
Channel: Interview DOT
Date: 2020-11-28

Click here - https://www.youtube.com/channel/UCd0U_xlQxdZynq09knDszXA?sub_confirmation=1 to get notifications.

CLEAN CODE TIPS | SOFTWARE DEVELOPMENT CODE REVIEW BEST PRACTICES | TIPS CLEAN CODE | InterviewDOT

WHAT IS CLEAN CODE ?
Clean code is code that is easy to understand and easy to change.

Ok, that sounds nice, but what does it really mean? Let’s break that sentence apart and examine the individual points behind it.

Easy to understand means the code is easy to read, whether that reader is the original author of the code or somebody else. It’s meaning is clear so it minimizes the need for guesswork and possibility for misunderstandings. It is easy to understand on every level, specifically:

It is easy to understand the execution flow of the entire application
It is easy to understand how the different objects collaborate with each other
It is easy to understand the role and responsibility of each class
It is easy to understand what each method does
It is easy to understand what is the purpose of each expression and variable
Easy to change means the code is easy to extend and refactor, and it’s easy to fix bugs in the codebase. This can be achieved if the person making the changes understands the code and also feels confident that the changes introduced in the code do not break any existing functionality. For the code to be easy to change:

Classes and methods are small and only have single responsibility
Classes have clear and concise public APIs
Classes and methods are predictable and work as expected
The code is easily testable and has unit tests (or it is easy to write the tests)
Tests are easy to understand and easy to change

If you write clean code, then you are helping your future self and your co-workers. You are reducing the cost of maintenance of the application you are writing. You are making it easier to estimate the time needed for new 
features. You are making it easier to fix bugs. You are making it more enjoyable to work on the code for many years to come. Essentially you are making the life easier for everyone involved in the project.

If you want your code to be easy to write, make it easy to read
— Robert C. Martin

Clean code always looks like it was written by someone who cares. There is nothing obvious you can do to make it better.
— Michael Feathers

Characteristics of a Clean code:
It should be elegant — Clean code should be pleasing to read. Reading it should make you smile the way a well-crafted music box or well-designed car would.
Clean code is focused —Each function, each class, each module exposes a single-minded attitude that remains entirely undistracted, and unpolluted, by the surrounding details.
Clean code is taken care of. Someone has taken the time to keep it simple and orderly. They have paid appropriate attention to details. They have cared.
4. Runs all the tests
5. Contains no duplication