Smell your JavaScript Code

Update2: I have created slides for this blogpost.

UPDATE1 : Before you read the article, Please do not assume this article is applicable for General purpose JavaScript. This article is applicable on — “Developing Extra Large Single Page Web Applications”!

Symptoms that you are doing bad coding for front-end JavaScript

Lets talk about JavaScript application with 100K LOC (0.1 million lines of code) or may be 1 million. How to manage such applications, how to test that you are productive. Here is a list so that you can test yourself that you are coding in a right direction or not. You can test that you are producing a good code or you are producing “spaghetti

  1. Fear

Do you fear touching your old codebase? Do you fear replacing your old codebase? Unable to Code Refactor

2. Magic

You do not know exact flow of your application because some framework in doing Magical Stuff for you.

Your application behaves in Magical ways.

Ex — I have added this code and it should but I am running with 10 millisecond delay and it is working.

Ex — this exact code is working in that place but copying here is not working.

3. Unpredictable

You are not sure — your code changes may affect some unknown part of the application.

Your changes leads to new bugs.

Ex — you know you changed the variable it should automatically appear in UI, but still things are not working, do i need to call $apply ?

4. Jugaad**

You yourself know that you are coding a Jugaad

because you are helpless*

  • ** — google it, see the image section.
  • * — may be because of framework

5. No Fine Control

Your framework or library forcing you in certain way .

Automate many things so that you cannot get control.

tools/framework/libraries are for your help & not to trouble you.

6. Code Duplication

You repeat same code and logic many places

You are unable refactor your code.

7. Dead End

With release of new version of framework you cannot migrate (Ex — Angular 2.0)

Why work with a framework/codebase with uncertain future or difficulty to migrate.

8. Unmovable Code

You cannot move your widget/module/component from one page (place) to another.

You code/module sticked to your DOM structure.

9. Obvious things take time

Sometimes things are so obvious but take time and efforts to complete

restricted by framework/library

10. Reproducing Bug !== easy

Reproducing bugs take long time.

Some times bug is very small but it take hour to setup and reach at that STATE

11. No Universal JavaScript

Its 2015, you are not using Universal (Isomorphic) Javascript

you are not rendering First Page from Server in your SPA

12. You do not develop your module/component/reusableCode separately.

Even for working on small component you load whole application. You do not develop that small component in isolated environment.

13. Frustration

While working you feel frustration, you do not enjoy. You wish, things should be easy. You feel that there is unnecessary complexity involved.


Please correct me or add more point.

Thanks

Narendra Sisodiya (@nsisodiya)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.