Upper and lower floors

Source: Internet
Author: User

The current development architecture is generally a three-or four-tier architecture. The lower layer always provides interfaces or methods for upper-layer calls. In this case, a problem occurs: when the lower-layer interfaces or methods are called, how do I verify the correctness of input parameters? If the two layers belong to the same project or company project, you may also check the source code to see if the implementation method of the lower layer of the comment verifies the correctness of the parameter, but if we use other class libraries, what should we do when we cannot see the source code? Even in the same company and project, the writers of lower-layer interface methods do not know whether the parameter should be verified correctly in each method, whether it is not null (this is the most common ).

At this time, everyone should abide by a business agreement, and many problems can be solved. Here are two small examples:

Action

Service

Page listdata ()


In, Action calls a listdata method in the service that returns the page type, and then performs slight processing to display the data in the page. In this scenario, the page does not really care about whether there is data in the page. The action does not check (and is not necessary) whether there is data in the page, as long as the data in the page is not null (it must be clear that there is no difference between data and null), the page returned by the listdata interface of the service must not be null.

If the listdata method in is changed to the getuser method whose return type is mapuser, there is another saying. Most of the application scenarios of the getuser method require the identification of objects with real data. If the parameters passed by the action cannot be found in the service, the service must not return a mapuser object without any data, but return NULL. Let the action make its own judgment and then do what it should do.

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.