Some of my best practices after 3 years as a developer

ThanhDat Vo
1 min readAug 21, 2018

--

Number 3

  1. A function or a variable must be named less than 3 words, best at only 1 word, for example: if component input only has on properties “onChangeInput”, the function name must be reduced to “change”
  2. In a Component, arrange 3 properties in a line in Component declared

Don’t repeat yourself (Don’t repeat third time and combine if possible)

  1. Don’t repeat logic code: repeated logic codes which appear more than twice should be written in utility file for later reuse
  2. Don’t repeat string: repeated strings which appear more than twice tends to be changed in the future should be written in a configuration file or constant file
  3. Don’t repeat metrics value: many metrics numbers which appear more than twice in the project, for example, the height of a View, the height of tab bar which is platform dependence (IOS and Android maybe difference) must be written in one file
  4. Don’t repeat Component: long Component, which repeats more than twice, should be written in common Component
  5. For variable which has the same type, for example, refUsername and refPassword, make an object name ref, which have 2 properties username and password
  6. For functions that have the same feature, for example processUsername and processPassword, combine to one function process and accept params type as a mark to use switch — case to process.

Before:

After:

--

--