DEV Community

Cover image for Bad Coding Habits Every Developer should Avoid
Mona Soliman
Mona Soliman

Posted on

Bad Coding Habits Every Developer should Avoid

*Code refactoring one of the most important thing we have to know it as a developers *

Here is some tips and tricks you can make it while coding:

1-Poor Names:

avoid meaningless, ambiguous, mysterious names. Try to make it simple and meaningful

2-Naming conventions:

Try to find the most used naming convention and if you use it completely with it in the whole project.

naming conventions like Pascal Case, camel Case, etc...

3-Poor Methods Signatures:

take a look at the method parameters, name and return try to make it meaningful and related to what the method does

4-Long Parameter List:

A lot of parameters are hard to understand and hard to use. Try to make the parameters three or less than three,this will help you to make your code cleaner

5-Variable Declarations On The Top:

You can declare variables close to their usage it will be much better and help anyone to understand your code quickly

6-Nested Conditionals:

If You have nested conditions, try to simplify them. Use a ternary operator to combine them or swap orders if it's available.

7-Duplicate Code:

Always follow the rule DRY

DON'T REPEAT YOURSELF

Don't repeat your code instead you can move the code to one place

8-Comments:

If your code already explains itself in this case you don't need to make comments try to make it when you need to explain why and how

9-Long Methods:

it's hard to use, hard to change, and hard to understand. Read more about the single responsibility principle it will help you to make methods short and related to one thing. And always remember things that are related should be together and things that are not related should not be together

conclusion:
Make your code simple and easy to understand, This will help you and the others

Top comments (0)