Applications [use] Design Patterns Refactoring design pattern of financial products centers

This article describes how to use the application of design patterns in the code design, through case notes describe. Business demand scenario referred to herein are: calculation engine, financial party access, rules of access products, product cost item reset. Through case reference design patterns include: Template Method pattern, chain of responsibility pattern, strategy pattern, factory method pattern, intermediary model, observer mode.

Significance application, design principles

Here Insert Picture Description

2, Secret design calculation engine

At present core financial products is the formula for the total amount of the car loan before the car loan lenders, so it is simply the cost of car loans is calculated around the items, these items include costs (cost platform, GPS, insurance, personal insurance, renewal deposit, etc.). Financial Products and systems design philosophy is different cost items stored in the form of rules for different products and auto stores also have different cost items of interest (such as loan interest rates, personal insurance rates, rates and other platforms). In view of this, the initial design is by breaking down each item cost calculator, through the first check, and then calculate the ideas of each calculator series, the final cumulative total amount of the car loan.

2.1, a flowchart of calculation engine

Here Insert Picture Description

2.2, application design patterns Introduction

Here Insert Picture Description

2.3, source code analysis

Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description

2.4 Scalability

Here Insert Picture Description

3, Secret design party access funds

Party funding package for the car loan is further abstracted product now includes new network, micro congregation, the Bohai Sea, Shanghai Pudong Development funds and other related parties, conditions for auto loans and hard money required, and the system supports setting the quasi-different latitudes of funds for different parties the conditions (including the main lenders access, vehicle access, access to loans), and different access include different conditions.
Main lender access (credit details, age, monthly income, driver's license to the person who engaged in industry, residence, etc.).
Vehicle access (whether second-hand car, vehicle, license plate type, mileage, vehicle age, etc.)
Loans access (repayment period, car loan amount, down payment ratio, etc.)
so we abstract these conditions package for property, executed in the form of chain of responsibility .

3.1, the classification rule conditions

Here Insert Picture Description

3.2, UML class diagram the relationship

Here Insert Picture Description

3.3 flowchart

Here Insert Picture Description

3.4 Design Patterns

Here Insert Picture Description

4, regular access Secret product design

At present, for vehicles and vehicle insurance discount is still based on the rules of form and configure the appropriate formula anchored on the car loan products, for a product, you can set different conditions for different allocation formula, for vehicles and vehicle insurance discount you need to return rule checking information .

4.1, traffic characteristics

Here Insert Picture Description

4.2 Rule Condition

Including: the actual sales price, vehicle loan amount, the total loan amount, down payment ratio, vehicle age, mileage, car and so on.

4.3, UML 类图

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

The scope of the abstract class: AbstractScopeRuleHandler
Here Insert Picture Description

Here Insert Picture Description

Interval class: AbstractRangeRuleHandler

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

5, the cost of the replacement item Secret product design

Suitable for car loans returned to dealers because of changes in the information, you need to call the interface of financial products based on the latest conditions of the interface returns the current cost of entry whether to reset the current situation. They include: interest rate gear, GPS gear, platform fees, personal protection scheme, the second annual premium in the third year premiums, renewal deposit, pilfer, account management fees.

5.1, traffic characteristics

Here Insert Picture Description

5.2, application design patterns Introduction

Here Insert Picture Description

5.3, UML 类图

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description

5.4, ​​other design patterns

Here Insert Picture Description
The following is my number two-dimensional code images public, welcome attention.
Autumn frost

Published 46 original articles · won praise 27 · views 160 000 +

Guess you like

Origin blog.csdn.net/shichen2010/article/details/84259217
Recommended