Empty object mode

Source: Internet
Author: User

Empty object mode    in empty object mode, we create an abstract class that specifies the various actions to be performed, and an entity class that extends the class, and also creates an empty object class that does not have any implementation of the class, and the empty object class will be used seamlessly where null values need to be checked . using an empty object instead of checking for null object instances, the empty object does not check for null values, but instead reacts to a relationship that does not do any action. Such an empty object can also provide default behavior when the data is unavailable. Source: http://www.runoob.com/design-pattern/null-object-pattern.html Do not use null objects in order to mask null should be kept null, much better than substituting "no value" with a non-null value. The empty object pattern is actually essentially the same as "replacing null with 0". When you are only trying to avoid null occurrences, do not use the null object pattern (NULL, the objects Design).
Imagine an example of a hotel booking. One user action for some reason, the hotel data becomes null, but the app runs "normal"-because we hate null, so we block it. The user then continues to operate on a "Nullhotel" and completes the operation. When the user actually found the hotel, he did not book any room. The hotel is full now, and 11:00 in the evening, no other hotel around ... I can't imagine what the user would think of the booking process ... Because the entire project masked the null error, no one found out the existence of the problem, so. It turns out he's been playing with a nullhotel.
Source: Why do we Love You--null (2. Scheme "0"): http://www.jianshu.com/p/ba4450785d24#: Why do we Love You--null (3. Empty object Mode):/http www.jianshu.com/p/77305ee74954



From for notes (Wiz)



Empty object mode

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.