Credit Business (Ali), credit business ali

Source: Internet
Author: User

Credit Business (Ali), credit business ali

1. credit business perspective

The credit business has two main perspectives: borrowers and investment institutions. Borrowers care about how much money they borrow, how much money they pay, and how much interest they pay. Institutions care about credit asset risks and benefits.

The two perspectives of the domain model are separated: Individuals ---> bills, organizations ---> assets. Investment institutions can be diversified (institutional interconnection ). One more organization (one more connection type ). Bills-institutional assets-institutional docking. Loan accounting, loan accounting, asset accounting, credit investigation, and credit management.

2. yundong · water loan

Yundun · water loan business: for customers who use the basic services of yundun exports, it provides unsecured, guaranteed-free, and pure credit loan services that accumulate credit lines with the export quota, this service was jointly launched by ** a number of banks. The flow chart below is the basic business process.

3. Reduce the use of if... else... in the code.

Many of our codes have different processing logic based on different types. The most typical conversion of different enumeration types:

public static CreditSource convertCreditSource(Short quotaSource) {        if (quotaSource == null) {            return null;        }        if (StringUtils.equals(QuotaSourceEnum.CMBSX.getValue(), quotaSource.toString())) {            return CreditSource.bank_cmb;        }        if (StringUtils.equals(QuotaSourceEnum.SUNSHINESX.getValue(), quotaSource.toString())) {            return CreditSource.ecreditbao_sun;        }        if (StringUtils.equals(QuotaSourceEnum.CMBCREDITLOANSX.getValue(), quotaSource.toString())) {            return CreditSource.creditloan_cmb;        }        if (StringUtils.equals(QuotaSourceEnum.CREDITBUY_BUYERSX.getValue(), quotaSource.toString())) {            return CreditSource.creditbuy_buyer;        }        if (StringUtil.equals(QuotaSourceEnum.CREDITBUY_SELLERSX.getValue(), quotaSource.toString())) {            return CreditSource.creditbuy_seller;        }        return null;    }

If you can change this code to the following method, will it look more concise?

    public static CreditSource convertCreditSource(Short quotaSource) {        if (quotaSource == null) {            return null;        }        return QuotaSourceEnum.parse(quotaSource.toString()).getCreditSource();    }

To implement this modification, we need to transform the following QuotaSourceEnum enumeration class:

Public enum QuotaSourceEnum {/** deposit credit source **/BZJSX ("1"),/** industry credit received in real time **/INSTANT_HYSX ("2 "), /** industry credit for accounting transactions **/ZHANGQI_HYSX ("3"),/** relational credit **/GXSX ("4 "), /** protocol credit **/XYSX ("5"),/** CMB credit **/CMBSX ("6 "), /** sunshine credit **/SUNSHINESX ("7"),/** China Merchants Bank Loan **/CMBCREDITLOANSX ("8 "), /** buyer credit **/CREDITBUY_BUYERSX ("9"),/** buyer credit **/CREDITBUY_SELLERSX ("10"); String value; quotaSourceEnum (String value) {this. value = value;} public String getValue () {return value;} public void setValue (String value) {this. value = value;} public static QuotaSourceEnum parse (String value) {if (StringUtils. isBlank (value) {return null;} for (QuotaSourceEnum quotaSource: QuotaSourceEnum. values () {if (value. equals (quotaSource. value) {return quotaSource;} return null ;}}

Modify:

Public enum QuotaSourceEnum {/** deposit credit source **/BZJSX ("1", null),/** industry credit received in real time **/INSTANT_HYSX ("2 ", null),/** industry credit under account transactions **/ZHANGQI_HYSX ("3", null),/** relational credit **/GXSX ("4 ", null),/** protocol credit **/XYSX ("5", null),/** CMB credit **/CMBSX ("6", CreditSource. bank_cmb),/** sunshine credit **/SUNSHINESX ("7", CreditSource. ecreditbao_sun),/** CMB loan **/CMBCREDITLOANSX ("8", CreditSource. creditloan_cmb),/** buyer credit **/CREDITBUY_BUYERSX ("9", CreditSource. creditbuy_buyer),/** buyer's credit to the seller **/CREDITBUY_SELLERSX ("10", CreditSource. creditbuy_seller); final String value; final CreditSource creditSource; QuotaSourceEnum (String value, CreditSource creditSource) {this. value = value; this. creditSource = creditSource ;}....}

I personally feel that Map is more concise than if-else. We also use the following strings for comparison:

StringUtils.equals(str1, str2);StringUtils.equalsIgnoreCase(str1, str2);

4. Add logic to Enum of enumeration class

Enum is not only an enumeration type, but also a special class. For example, we recommend using enum in objective Java to implement the singleton mode. As a class, we can add logic to it, put the logic related to it inside it, instead of simply taking it as enumeration, and then make if-else judgment externally. For example, our code has the following logic:

5,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.