What are some bad programming language practices every programmer needs to be aware of in order to avoid them?
There are thirty-five common bad programming language habits.
Well, there are probably more, but thirty-five sounded cool and that's all I could think of. I put the most important ones at #17 and #35 because I'd like you to read the full answer. I think you'll find it valuable.
1. Acting like you have all the answers. Don't cling onto the insecure feeling that you have to know everything. You don't. And that's ok.
2. Attending meetings all day. If you spend most of your day in meetings, you should consider spending your time more productively.
3. Acting defensively when someone critiques your code. The best developers are willing to have an open and straightforward conversation about the code they've written and how it can be improved.
4. Giving up too soon. Too many programmers get so close to a solution, only to give up right before they're about to solve the problem.
5. Refusing to ask for help. By going through the process of articulating your problem to someone else, you'll often discover the solution. This is what is known as "rubber duck debugging."
6. Passing blame to others. The most valuable developer is the one who takes ownership and responsibility for the code they write.
7. Writing code that prematurely optimizes other code. In most situations, the performance advantage gained from fully optimizing code to the point that it's difficult to understand is not worth it.
8. Ignoring the opinions of other developers. One of the best ways to learn and grow as a developer is to pair program with developers who have more experience than you. Go seek out other people's opinions.
9. Not knowing how to optimize code. There are some situations where performance is a big issue, such as problems with:
- Algorithmic Complexity
- Inefficient Database Operations
- Third party APIs
- N+1 Queries
When performance issues arise, you need to know how to analyze them, understand what is taking the time, and how to fix the problems.
10. Undervaluing relationships with other members of the team. You are hired to write code. But you need to be able to interact with other members of the team, too.
11. Engaging in office politics. Sometimes, other development teams will make decisions that you think are incorrect. But as long as you can accomplish your team's objectives, it's best to simply work around other teams' quirks, rather than fighting them too hard.
12. Freezing under pressure. When you operate in a scenario where users cannot use the product, there is a ton of pressure. You need to develop the ability to stay calm and get the job done.
13. Being incapable of writing bad code. In the real world, there are trade-offs based on things like:
- Urgent bugs that need to be fixed immediately
You need to have the mentality that it's ok to write bad code to fulfill the demands at hand.
14. Over-engineering simple problems. Don't create confusing solutions for easy issues.
15. Acting like a boss. Not a leader. Too many developers don't know how to manage other people. You should be the person who other devs turn to for guidance and direction- not just step-by-step instructions.
16. Using the wrong tool for the job. Stop making decisions based on "it's what I know." You need to be open to using different technologies, languages, and frameworks.
18. Not maintaining a good grasp of your tools. Since you'll spend a large number of hours using things like text editors, the command line, and other tools to write code, it's essential to master them. Take the time to learn the tips and tricks that make you more efficient.
19. Avoiding error messages. Code errors happen frequently. They also generally include very valuable information about what went wrong, why it happened, and what lines of triggered the problems. You should seek out error messages, rather than try to avoid them.
20. Counting the hours. The best developers enjoy the time they spend writing code and find themselves getting lost in the in it. It's not like something will change after you code for 10,000 hours.
21. Refusing to learn from mistakes. This is counterproductive. When mistakes happen, just zoom out and understand these three things:
- What was the ultimate cause of the mistake?
- Could processes or behaviors be put in place to prevent this category of mistake from happening in the future?
- Could the mistake be detected sooner and had less of an impact.
Refusing to learn from your mistakes will cause you to repeat them.
22. Being afraid of throwing away code. Know that spending three days to write the wrong solution will teach you more falling victim to analysis paralysis.
23. Romanticizing your developer toolkit. Some developers love the text editor known as vim. Others hate it and love the text editor known as emacs. But there will be scenarios where it makes sense to use one over the other
24. Separating yourself from the developer community.
There are programming communities all over the place. With organizations like Railsbridge
, Girl Develop
Itand events like RubyConf
and much more, there's so much to discover.
26. Not giving back to the community. You should embrace the programming community as early as possible. If you do so, you will realize how helpful and friendly it is.
27. Struggling for hours to solve something, solving it, and not documenting it. Every so often, you'll encounter a strange, really specific problem that someone on the Internet hasn't solved yet. After spending hours cracking the code on your own, it's your duty to write the post so that you can help the next person who encounters the problem.
28. Writing too many or not enough comments in the code. Comments are essential notes to developers. But like anything, they should be done in moderation.
29. Lazily refusing to update issues for product managers. It's important for PM's to get timely updates and know the status of the product (within reason). If you don't update the issues in a timely manner, it can cause a lot of headaches.
30. Frequently bundling unrelated features into the same initiative. It can be easy to get into the habit of grouping two unrelated things into the same initiative. And if the two different things are both large in scale, untangling the issues can be super complicated.
31. Carefully coming up with a smart plan with other members of the team, only to completely abandon it and change course entirely when one unexpected thing happens. This is pretty much the worst thing you can do.
32. Sticking to a thought-out plan that clearly isn't working. The only thing worse than abandoning a plan at the last minute is refusing to stop executing a bad idea.
33. Consistently apologizing for the bad code you're writing. If you find that you're apologizing for bad code on a consistent base, it could mean that you need to reevaluate your deadlines.
34. Not spending the energy you should be performing code reviews. The development team is in it together and it is every team member's responsibility to make sure the code that every other member is contributing lives up to the high standards of the team.
35. Not spending enough time mentoring other devs on your team. It's your job to ensure that your team is learning, growing, and becoming better at programming on a regular basis.
I strongly believe that every developer is a work-in-progress. So it's totally normal and ok to have these bad habits. In fact, the key to improving as a developer or as any other type of professional is to follow three steps:
- Recognize that you have bad habits.
- Find the motivation to change them.
- Turn that motivation into practice by eliminating bad habits and developing good ones.
If you read this answer, you just finished step one. Now it's time to go after the next two.