Many clients and versions will be encountered during APP development interfaces. There are a lot of if judgments in the Code. How should I design this item to make the code and logic clearer and easier to maintain?

Source: Internet
Author: User
Many versions (andriod1.2.3.2, iphone1.2.2.3, ipad2.5.3.1.) will be encountered during APP development interface ...) many clients (Android, iphone, and ipad), because the products are iteratively developed, different clients may have different versions of the design logic, resulting in the code... many versions (andriod 1.2.3.2, iphone 1.2.2.3, and ipad 2.5.3.1...) are encountered during APP development interfaces ...) many clients (Android, iphone, and ipad), because the products are iteratively developed, different clients may have different versions of the design logic, as a result, there are a lot of such if judgments in the code, and the maintenance and code readability are very poor. How can this design make the code and logic clearer and easier to maintain?
Or what design patterns should this product meet or meet when writing code?

Reply content:

Many versions (andriod 1.2.3.2, iphone 1.2.2.3, and ipad 2.5.3.1...) are encountered during APP development interfaces ...) many clients (Android, iphone, and ipad), because the products are iteratively developed, different clients may have different versions of the design logic, as a result, there are a lot of such if judgments in the code, and the maintenance and code readability are very poor. How can this design make the code and logic clearer and easier to maintain?
Or what design patterns should this product meet or meet when writing code?

The APIs on the major version can be differentiated by URLs. different versions of the backend are deployed on different addresses, such
Http: // xxx/api/v1/xxxx
Http: // xxx/api/v2/xxxx

Iterative development does not mean that you can modify the interface without complying with any constraints. if there are many items, it means that your interface is not well considered in the design at the beginning. If you release a product that is iterated in this way, do you have to worry about yourself.

I suggest you read a book titled refactoring: improving the design of existing code. There are several different practices for if ..

In addition, do I think these logic or version judgments can be maintained in a static file?

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.