How to refactor a system
Find a very interesting situation, do the system write code for many years, meet the requirements are basically implemented in the existing system, the system from the beginning to achieve basically no.
1 why
Whether it is to implement a system from the beginning, or to maintain a system, then the implementation of the technology may be the most advanced, planning the product logic is reasonable, with the development of time, the developer changes, the system code quality will gradually decay, add a feature too troublesome, Changing a bug involves too many modules-no single-test-free solution, and the business side complains that the technical team is responding too slowly. It's time to refactor the system.
For technical teams, refactoring capabilities affect how quickly the system responds to the business team. Many job openings require:
Reconstruct and optimize the existing system;
Have a wealth of experience in the reuse and reconfiguration of components;
Able to skillfully use various reconstruction methods;
Realize the realization problem, propose the improvement (reconstruction) plan;
The framework itself has a deep understanding of the system and application experience, the framework itself has been developed or re-construction can be given priority
...... Technicians with the ability to reconstruct are also very competitive in terms of personal value (^o^)/~
2 How
When refactoring the system, technicians should consider the rational use of legacy code, third-party code, open source code, and the latest technology, completely from scratch, and not allowed in time or complexity of business.
Based on personal development experience, I think we should divide refactoring into 3 different types: Code refactoring, module refactoring, and architecture refactoring.
Code refactoring: This also system business relationship is relatively small, more is good coding rules follow and implementation. For example: Unified error Exception throw and processing scheme, easy to understand the return value model, unified validation rules, based on the design pattern 6 principles of coding, single test case of the completion and maintenance. This type of refactoring is easier to implement and has no effect on the existing clerk logic.
Module reconfiguration: The technical team must meet the needs of the daily development, but also to do the reconstruction of the original code, development resources are certainly not enough, the more reliable solution is to select a new demand-related, and other business modules with lower coupling ratio of business modules to restructure, re-carding business processes and technology implementation solutions, The implementation of this part of refactoring relies on code refactoring, Good coding specification and code quality is the cornerstone, and familiarity with the relevant business is the skeleton. The entire process has been iterative to complete the entire system of the reconfiguration of the module, the process requires the technical team based on code, from code-level thinking to design-level thinking, abstract the current design model, to consider adapting to the various scenarios brought about by the scalability, maintainability of the pressure.
Architecture refactoring: This is a heavy-weight refactoring, and if you step through the refactoring of Code refactoring, the first 2, then the architecture refactoring is quite natural and easy to implement. If you start over, your current business needs are suspended, and the technical team is under a lot of pressure to work overtime to reduce the need for business response.
Reference: http://www.programmer.com.cn/4555/
How to refactor a system