The maintenance of code is not achieved overnight. In the maintenance phase of business, if the project code cannot be effectively governed, the business code will gradually become bloated and its maintainability will be reduced.

Functional separation & integration

In the process of business development, the original single function is derived from different business models and logic. The orderly sorting of code can better help to reduce the maintenance cost of subsequent iterations.

Function (logic) aggregation

  1. Extracting the same functionality to the upper layer (toolkit) reduces the dispersion of logic and increases encapsulation

Functional isolation (boundary demarcation)

  1. Code warehouse (function) should be properly divided (divided into dimensions of business relevance/technology stack form) to prevent mutual interference between different businesses.
  2. When providing business functions, the internal logic can reduce the interpretation of the outer layer logic, and encapsulate the outer layer of interpretation logic at the boundary. New Date(year, Month,day) {new Date(year, month,day) {new Date(year, month,day); Consistent meaning to provide conversions uniformly across exposed interfaces

Standard to establish

  1. Code specification (Lint Commit rule)
  2. Branch specification (Online specification)
  3. Review mechanics (how can long-term reviews be better than cutscenes? The master of business?
  4. Semantic (readability), comments
  5. Catalog normalization (uniform reference mode)

Business-based framework (functional reuse)

Building wheels is an appeal at a certain stage of technical/business development. Let the framework constrain and empower the business by sinking development capabilities, online capabilities, and business common logic down to the framework layer.

Gradual change

Delays in the abstract

Delay the encapsulation of abstract logic to the code, excessive pre-encapsulation will lead to the encapsulation of modules is not good for maintenance, and it is painful to split the functions when the functions of different modules differ greatly. In the following example, only the lowest level modules can be encapsulated in the initial stage, and the business logic can be encapsulated upward in the later stage

Code is a language for interacting with machines and a way for developers to communicate with each other. The idea of writing maintainable code is to create a uniform dialect within the same team. This unique dialect is intended to improve the efficiency of development to a certain extent (a bad dialect may reduce the efficiency of development). Maybe the team will use one dialect for a while, and another dialect for a while. My advice is to think about the differences between dialects and why this pattern fits into the present situation, and gradually you will develop your own dialect or way of thinking.

reference

Code quality and specification, the technical debt you owe over the years what are some of the best ways to improve Code quality

Welcome everyone to pay attention to my public number – front-end small bench together to learn progress!