Code Quality
react component level separation

Code Quality

Hi, Today I am going to write my first article on linked in. I was very excited and also confused to on what topic i write. Then I got an idea in my mind that why not to write on my current activity.

And that is improving code quality and also making habit to write quality code. So in this article i am going to share some code quality things and what improvements i did/doing when i am writing a code.

There are many things which is used to make quality code.

  • Maintainability: Code must be maintainable in future by another developer and also by you. Some times we also can not able make change in our old code. I made some changes in my code writing style like i separated code in functions so it would make easier to change code and maintain it.
Make reusable functions that will use in more than one place.
Don't separate single thing code into multiple functions.
  • Documented: Now a days i am using this technique very much. Whenever I am creating any function I add some comments (jsDoc for javascript) to explain its role and functions. Also whenever i am changing code anywhere that time add some comments above that code snippets to explain what the code does.
/**
   * this method used to convert model tree structure 
   * in to simple array list. 
   * @param {Object} data 
   * @param {Number} col column of container field 
   */
  prepareList(data, col = 1) {
   ...
  }

Above i share some code snippets to show you how i made habit to make code documented. You can use your own way to add documentation also.

  • Separation of concerns: Second technique help me a lot to increase maintainability of code. I separated lot of my old code in to separate files and functions.

React specific: I separated lot of render code in to small components. Also you can make some reusable flexible components to save future time.

For today it's enough. I shared lot of things which i have implemented and tried to make it my habit for coding. I hope this article will help to other peoples to improve coding style and code quality.

Thank you

要查看或添加评论,请登录

社区洞察

其他会员也浏览了