App development interface will encounter a lot of clients, version, in the code has a lot of if judgment, this block should be how to design code and logic clearer, maintenance easier?

Source: Internet
Author: User
App development interface will encounter many version (Andriod 1.2.3.2, iphone 1.2.2.3, ipad 2.5.3.1 ...) Many clients (Android, iphone, ipad), because the product is iterative development, may be different client different version of the logic of the design, resulting in the code there are many such if judgment, maintenance and code readability is very poor, this block should be how to design code and logic clearer, Easier to maintain?
Or what design patterns should the product conform to, or when the code should be written?

Reply content:

App development interface will encounter many version (Andriod 1.2.3.2, iphone 1.2.2.3, ipad 2.5.3.1 ...) Many clients (Android, iphone, ipad), because the product is iterative development, may be different client different version of the logic of the design, resulting in the code there are many such if judgment, maintenance and code readability is very poor, this block should be how to design code and logic clearer, Easier to maintain?
Or what design patterns should the product conform to, or when the code should be written?

APIs on large versions can be directly differentiated by URLs, and different versions of the background are deployed to different addresses, such as
Http://xxx/api/v1/xxxx
Http://xxx/api/v2/xxxx

Iterative development does not mean that you can not abide by any arbitrary changes, there are many if, that means that your interface in the beginning of the design is not considered good enough. Putting a product out of an iteration in this way is not a pit of your own.

It is recommended that you take a look at a book called Refactoring: Improving the design of existing code, with a few different approaches to if.

In addition to this, I think it is possible to put these logic or version judgment in a static file to maintain?

  • 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.