on
How to write a Clean Code?
There are two things - Programming and Good Programming.
Programming is what we all have been doing. Now, is the time to do good programming. We all know that even the bad code works. But it takes time and real hard work to make a program good and presentable. Moreover, other developers tease you when they are not able to find what all is happening in your code.
This blog will give you a lot of knowledge on what are the best practises and how to actually write code.
Though I myself make great effort to better my code every single day. :p
I hope after reading this blog you can become a good and sorted programmer.
Characteristics of a Clean code :
- A code should be elegant.
-
Code should be pleasing to read. Reading it should make you smile the way a well- crafted music box or well-designed car would.
-
Code should be focused - each function, each class should represent a single-minded attitude that remains entirely undistracted by the surrounding details.
- A code should not contain any duplication.
Meaningful Names
A good coder shoul use intention revealing names. Choosing good names takes time but saves more than it takes. The name of a variable, function, or class, should answer all the big questions. It should tell a person or other programmer why it exists, what it does, and how it is used.
If a name requires a comment, then the name does not reveal its intent.
Class Names
Classes and objects should have noun or noun phrase names like Customer, and AddressParser. A good coder should avoid words like Manager, Processor, Data, or Info in the name of a class. A class name should not be a verb.