Design Patterns and America - reconstruction

Why reconstruction

Refactoring is the time to ensure code quality as a means of avoiding corruption to the point where the code can not be maintained, but also to avoid excessive preliminary design. Excellent products are iterative out, we can not predict in advance of future demand, so the reconstruction is unavoidable.

Reconstruction of two ways

Large reconstruction

Reconstruction of the relationship between the systems, modules, code structure, type and the like, the reconstruction means are: a layered, modular, decoupling, abstract reusable component. Such reconstruction will change the code is relatively large, relatively deep impact.

For example, we have a lot of code that determines if else then we reconstruct extract an abstract class according to create different processing conditions

Small reconstruction

Reconstruction of code level classes, functions, variables, etc., such as naming specification, specification annotations, to eliminate large class or function, repeated extraction code, etc.

When reconstruction

Focus on code quality in the daily development, rather than wait until a problem when it is unified reconstruction. For large-scale reconstruction more difficult, it must be organized and planned in small stages of reconstruction. Combined with small-scale reconstruction unit tests can be done at any time.

Guess you like

Origin www.cnblogs.com/LQBlog/p/12208318.html