Duc Mai

Full stack developer


Keep your code clean, organised and maintainable

Keep your code clean, organised and maintainable

It is always beneficial to work with clean, well organised, well documented code base. But how to do that? here are my tips

After years in the industry, I have several rules for coding that I always try to keep myself strictly with.

  • The first rule is that no circular reference code. I am against code that have mutual reference which can lead to difficult problems later. The recommendation is that separate shared things to a place that can be reused. Code should be separated clearly by several layers, the lower layer should not make any code calls to the upper.
  • The second rule is that "Single source of truth". For handling with data, I always prefer to have single source of truth. This thing can be seen a lot when working with react state. So my rule is simple that if props is truth then state should be updated accordingly. Or another scenario is the choice between data in redux and context, I would choose only one not to mix them.
  • The third rule is that no components longer than 300 rows. This is just from my own experience, when I need to dig into a component longer than 300 rows then I will get tired easily. Components in medium size is also easier to maintain.
  • The forth rule is to do things simple first but need to** have room to update** in the future. Any strange things done because of the business should be documented by comments or documentations.
  • The fifth rule is to refactor code every period like 2 months. From my own experience several parts of the code can be deprecated or improved after certain period so we should spare time every x months/weeks to see over what code we can remove or improve.

About me

How I describe about myself

A developer cares about climate changes and environments

A full stack js developer

A developer is interested in cloud technologies

A challenge lover


English, Swedish, Vietnamese

Duc Mai
Duke Mai
Duc Mai