Unity (v): Using scene Ⅱ: For single case mode

Source: Internet
Author: User

Single case mode

As for the single case pattern itself, I don't think I can say it here, it's the simplest one in the pattern. I just want to talk about my idea of this model.

In order to implement a singleton pattern, it is common practice to define a method in a class such as getinstance, to determine if the instance is null to create a new instance, or to return an existing instance. But I think this is a way of coupling the lifecycle management of objects with the class itself, against the SRP principle. So I think that where you need to use a single example, the responsibility for lifecycle management should be shifted to the object container, and our class is still a clean class.

For the next instructions, let's write a few of the interfaces and classes that are needed later: prep work

Iorder interface, Commonorder class, Viporder class:

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.