Don't practice until you get it right. Practice until you can't get it wrong!
Hey, Techies! 🤺
How was your day going till now? 😎
in this article I wanted to share with you some bad coding practices I had before when I started to code but I want you to stay away as much as possible from this horrible mistakes I did it before.
So without wasting another minutes of your valuable time, Let's get straight into it ✌️✌️
1. FAILING TO THINK AHEAD
What features should your project have, how much will it be expected to scale, how many users will it have and how fast must it run?
You need to answer these questions before starting your project or early in the process. Otherwise, you may face serious difficulties.
Twitter provides a good example of the problems you encounter if you underestimate future requirements. Twitter had to abandon Ruby on Rails and rewrite much of its code using Scala and other technologies because the Ruby code, as originally architected, simply couldn't scale to keep up with Twitter's fast-growing user base.
2. OPTIMIZING CODE PREMATURELY
Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered.
Premature optimization can introduce an unexpected bugs and be a huge time waster.
The first step should be to ship code that works, and then figure out which critical components, if any, to optimize for performance.
Being clever with your code may make it run infinitesimally faster, but it makes it far harder to debug and maintain.
A better strategy: Write your code clearly, then get to work in any parts that really need optimizing in order to improve performance.
3. FAILING TO MODULARIZE
You should write functions that do one thing and one thing only.
This helps keep them short and easy to understand and maintain.
Long functions have many possible paths through them, making them complicated and much harder to understand and test.
A good rule of thumb: One function should occupy no more space than a single screen. Another one: If it has 10 or more "if" statements or loops, then it's too complicated and should be rewritten.
4. NOT COMMENTING YOUR CODE
Code comments are so widely misunderstood and abused that you might find yourself wondering if they're worth using at all. Be careful what you wish for.
It is the responsibility of the programmer to write obvious code and try to eliminate the need for comments.
However, comments are still helpful and even necessary in many situations and avoiding them can make your code unreadable.
5. FAILING TO FORMATE YOUR CODE
Code formatting is very important when you are building an application.
This will help you to organize your code properly and to maintain your code to make it easily readable.
Indenting and formatting your code makes it easier to understand at a glance and, therefore, spot mistakes.
It also makes it far easier for other people to maintain your code, as It's presented in a consistent fashion.
If you use an IDE that doesn't automatically format your code, consider running it through a code beautifier such as Uncrustify, which will format it consistently according to the rules you configure.
6. IGNORING ERROR MESSAGES
Good error messages are helpful and tell you what you should do.
Having more information about a problem is always better, and taking the time to gather that information will save more time in the long run.
That's all falks for this article.....
What other bad coding practices programmers should avoid?