SIMPLE TIPS TO WRITE CLEAN CODE >⠀
SIMPLE TIPS TO WRITE CLEAN CODE </>⠀
⠀
๐Write it for people⠀
It is true that code is interpreted by machines, however, we shouldn’t neglect its readability. The easiest way is to use whitespaces.⠀
๐Add comments correctly⠀
If you write clean code, people will understand “how”, but they won’t understand “why”. Add comments to tell readers why you choose those ways and algorithms.⠀
๐Use meaningful names⠀
You should use meaningful names for variables, functions, and methods. Meaningful names are descriptive enough that people will be able to understand their purpose.⠀
๐Let it perform only one task⠀
Every function or method should perform one task only. This way they will be more predictable and easy to understand. This is called the Single Responsibility Principle.⠀
๐Be Consistent⠀
Find common conventions and standards in the community of your programming language and try to stick to those everywhere.⠀
๐Review your code regularly⠀
Simply writing clean code is not everything. The next step is to keep your code clean. Clean code requires maintenance. You should review your code on a regular basis.⠀
⠀
๐Data Structures and Algorithms Made Easy: Data Structures and Algorithmic Puzzles Paperback – 2016 by Narasimha Karumanchi (Author)
What are your strategies to write clean code? Share your ๐ญthoughts in comments⠀
______________________________
Comments
Post a Comment