Jessica | Javascript🚀
Jessica | Javascript🚀

@jesss_codes

10 Tweets 46 reads Jun 30, 2021
7 Best Tips to Write Cleaner Code
Thread 👇
Table Of Content
1. Keep It Simple
2. One Function One Job
3. Use Meaningful Names For Variables, Functions, And Methods
4. Use Comments For Clarification
5. Be Careful With Dependencies
6. Use Proper Indentation And Spacing
7. Use One Statement Per Line
1. Keep It Simple
The first and the most basic tip is to keep your code as simple and readable as possible. Don’t get fancy if you don’t have to, and don’t over-complicate problems. By keeping it simple you can produce higher quality code, solve problems faster.
2. One Function One Job
Most beginners do this mistake, they write a function that can handle almost everything. It makes your code more confusing for developers and creates problems when they need to fix some bugs.
Let every function, or method, perform just one task.
3. Use Meaningful Names For Variables, Functions, And Methods
Using a naming convention is a great way to get started — it keeps things clear and lets you know exactly what you’re working with. It also means you won’t accidentally try to use a string of text in a math equation.
4. Use Comments For Clarification
Adding comments to your code can be invaluable — they can quickly show what a complex function is doing, or maybe even explain why certain things need to happen in a certain order. But don’t write comments where it’s not necessary.
5. Be Careful With Dependencies
In software development, you really need to be careful about your dependencies. Use software's like dependency walker to know the exact dependency for the binary not all others. This drastically decreases the size of your code and final executable
6. Use Proper Indentation And Spacing
Reading smashed-together, spaceless code is not the most pleasant experience. Hence it is extremely important to use whitespaces. Don’t hesitate to add blank lines to separate code blocks and avoid sticking too much code in one line.
7. Use One Statement Per Line
You should write your code as if you’re writing a story that you can read from top to bottom (without having to scroll horizontally). Each line should be easy to read and correspond to one distinctive idea/action.
I usually post such Threads here on Twitter you can follow me @jesss_codes, to never miss upcoming Programming and Tech related stuff.
Thank you, ❤️

Loading suggestions...