EDITORIAL: Design Patterns from life, and more important than life!
Why use design patterns to refactor the code
What is the strategy pattern
Strategy Mode is a package of algorithms, and algorithms use is the responsibility of segmentation algorithm itself off, delegated to a different object management, and ultimately can be achieved to resolve the multiple problems if judgment .
Strategy mode scenario
For example, to build a polymerization time payment platform, this time the need butt many third-party payment interface, such as Alipay, micro-channel payment, UnionPay payment. By tradition the code to determine if the maintenance of the latter is very poor!
This time can solve the problem by determining if multiple policy mode.
Copyright @ a moment apart https://my.oschina.net/u/3995125
Strategy Mode Chart
Strategy mode environment to build
Maven dependency information
PayStrategy (abstract role)
ConcreteStrategy (concrete realization of the role)
PayContextService (context)
SpringUtils
Database access layer
Database access layer
Mapper layer
Base Returns Info
Controller layer
application.yml
Startup class
effect
Copyright @ a moment apart https://my.oschina.net/u/3995125
Reference article: Ant classroom: http://www.mayikt.com