Handle the amount of offline computation in bridging mode
The last personal version, the money on and off the machine is part of the strategy + responsibility chain, (for details, see: http://blog.csdn.net/lhc1105/article/details/30713331) and then because the call method is too much, added a look, the processing is a bit complicated, and it seems that the mode is a little stiff.
This cooperative edition removes the design pattern and uses another design pattern to process it.
This time, the bridge mode is used:
Because the downtime is affected by the calculation of money to two parameters, one is the user type and the other is the charging policy, the two changes are separated in the bridging mode, it is easier to expand and cope with changes than to write N * M policies in the past. You can add many types of users or write many billing methods, if there are many sub-classes in both directions, the N * M combination will be very large. This structure is a dynamic generation strategy compared with the main policy mode, it is more flexible than writing all policies in advance.
Conclusion: The design pattern is quite interesting. When you use the Personal Edition, you can add it. When you get to the partner edition, You can rethink your own pattern to optimize it.