Structural mode-adapter mode learning demo

Foreword:

In the current agile development, following the iteration of the requirement version, some business functions, under the influence of different indicators, when the business rules under some indicators change greatly, the code may need to be refactored.

Or when replacing the old version of the code, newcomers dare not change the complex business code at will without a manual.

Can a large number of if and else codes be added to maintain old functions? Old codes are used for indicators that are not involved, and new codes are used for those that involve a large number of changes. When external pages are called, there is only one entry;

At that time, what was discussed here only involved simple structural adjustments, using the adapter pattern to simply maintain historical code,

If you want to refactor, you can also use creational patterns such as simple factories, for example: simple factory pattern

TODO perfect next time

Guess you like

Origin blog.csdn.net/qq_44691484/article/details/130955737