Want to avoid these common mistakes that could cost you your coding credibility?

Want to avoid these common mistakes that could cost you your coding credibility?

Developing the program can be challenging. Sometimes programs are not working as we expect. There are different types of bugs you can easily find with a quick search.

So let us focus on experimental tips that I found in the last 6 years of programming and helped me a lot to avoid producing bugs and increase the quality of the code base:


📍 Null | Undefined: 

One of the most common issues that always need to be checked is mistyping or undefined issues, especially in objects. Therefore, some of the samples will be: 

  1. Before using array functions/attributes like .lengh or .filter(), ensure the type is an array, not other types or undefined.
  2. Restricted typing (type safety) can help a lot with the absence or existence of attributes (use Interfaces DTOs as much as possible)
  3. Optional fields in the database can provide this issue too. Try to give constraints or valid schema as much as possible and prevent keeping data as an unknown object.


📍 Trace Complex conditions: 

Make sure the combination of nested Ands and Ors works properly

 

📍 Test your function outside the codebase!

Sometimes it takes work to provide the situation to test a code block. In this situation, I will write a code block in a function and retest the method functionality in a separate playground file. If the function with the right inputs provides the correct outputs, your code works fine!


📍 Uncovered scenarios: 

Algorithms are the most critical part of programming. As a developer, it is significant to think and cover all scenarios that may happen in the real world. So thinking about how I should implement the feature is 90% work, and if needed, I provide pseudocode for myself, and then the most accessible part is coming. Listen to some music and translate your thoughts to code.


📍 Misunderstanding: 

One of the widespread issues in dev teams is miscommunication and the absence of ubiquitous language. So it's vital before accepting the task and providing an estimation, try to find out the:

  1. - what is the purpose of this feature? 
  2. - what if + [different scenarios]
  3. - share limitations on the current implementation 
  4. - think loudly with your teammates and ask them to participate in brainstorming (this part is not wasting time and will decrease blockers in further steps)


📍 Laziness (Provide your own checklist) 🙂:

An important point here is that we are all human, so it's okay that sometimes we are not in a good mood. However, programming based on the mode in the long term will decrease efficiency; I always try to have a checklist for each development iteration. 


📍 Wisely use your IDE to check the side effects of changes:

One of the most challenging parts of implementation is to change some parts of the code. Before that, you need to search for usage of this function in the entire project. For renaming and replacement, I recommend using IDE features implemented for this usage and double check with Git which parts have been changed and... Do not forget to check the changed parts! It's a little bit hard, but it will help you in the future when you see a bug and forget about details.


📍 Don't be afraid to read other developer's code:

One of the most critical parts of being a developer is to read other developers' code. Many developers prefer to rewrite the code instead of improving or reusing it, and this can provide a lot of inconsistency in the code base. For example, imagine we have function a() in the utils file, and instead of reusing it, you will spend a lot of time rewriting it and some parts we use to function a() and other details of your new function.


📍 Do not forget to use logs and observability tools:

Debugging sometimes is much more complicated than writing code. In previous tips, I tried to help to decrease the number of bugs, but in general, bugs are part of programming, so it's crucial to learn how to find them. Logs are essential; as you know, they can decrease performance because of I/O bound culture. But in general, if you use them wisely, they can save you time/life in future. During the implementation, I also think about when to put these logs.


In this short article, I shared my experience and tricks that helped me work more smoothly and manageably. I hope it can be helpful for you.

Omid Shams ,

Node.js Developer at S-PRO

Onyinye Mofunanya

Operations & Strategy Professional| Emerging Business Leader

2y

This should be interesting 👋

Like
Reply

To view or add a comment, sign in

Others also viewed

Explore content categories