Photo by Ben White on Unsplash

How You should not write code | JavaScript | TypeScript

Deepak Vishwakarma
The Startup

--

This is an article from mini-series of How you should not write code. The next part of this section is How You Should Not Write Code — JavaScript, Part-2

There are many articles on the web on how to write better and clean code. I had emphasized the words clean and better. I think by the time all of us had adopted those concepts in day to day coding life. However, sometimes I feel that we do over-engineering and copy-paste things. It is to save time.

In this article, I will highlight some of the coding practices or code smells that we should either drop or don't follow it.

Table of content

  1. Dependency Injection
  2. Use of special char for private variable
  3. Explicitly assigning null as a value
  4. Use of traditional for loop
  5. Try-Catch Hell
  6. Long path imports

1. Dependency Injection

I have seen many libraries that use dependency injection. DI(Dependency Injection) makes code more readable and maintainable. However, This is not a valid case for JavaScript. JavaScript is a dynamic language. You can modify the context of the object or constructor on runtime.

--

--

Deepak Vishwakarma
The Startup

I am a polyglot Blockchain Developer. Mainly work on JavaScript and Nodejs. I work for a multinational Bank as Tech Lead to define the best architecture.