About the robustness of code

Source: Internet
Author: User

There are many customers today that reflect ourAPPthe one that opens up crashes because it's the home page that I do and I open it right nowapp Look,sure enough. My colleague.DebugThe code, the original homepage of theBannerpicture return isNULL, which is returned from the service side, which we have no control over. But is our client not responsible? We do the client does not guarantee that the server must have returned to US data, in some cases may beNULL. That's exactly what happened today. Look at my code, I added a layer of judgment on the home page returnedModelthe object of the class is not empty, but is not judgedBannerreturns whether the picture information is empty. If it's empty, I'll assign it to theViewpager, certainly forCrashthe. Then I added a layer of judgment whether it was empty. Even if no picture is returned, the app won't crash. Which information to use, it is necessary to determine whether it is empty. The return of the data returned by the server can be null, but we cannot let the appCrash, the information does not show no relationship, but try not to let the app haveCrash, which not only has a poor user experience, but also shows that the programmer's code is not robust enough. I will try to write strong code in the future, this habit is very important to a programmer.

About the robustness of code

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.