[Design mode] Status Mode

Source: Internet
Author: User

OO Basics

Abstraction

Encapsulation

Polymorphism

Inheritance


OO principles

Encapsulation changes

Multi-Purpose Combination and less inheritance

For interface programming, not for implementation programming

Efforts to design loose coupling of interaction objects

Class should be open to extensions and closed to changes

Dependency abstraction, not dependent on detailed classes

Just talk to friends

Don't look for me, I will look for you

Class should have only one reason for change


OO Mode

State mode-agree to change the behavior of an object when its internal state changes. The object seems to have changed its class.


1. The State mode allows an object to have different behaviors based on its internal state.

2. Unlike the program state machine, the state mode uses classes to represent the State.

3. context will entrust the behavior to the current State object.

4. By encapsulating each State into a class, we will localize whatever changes need to be done in the future.

5. The status mode and Policy mode have the same class diagram, but they have different intentions.

6. The context class is usually configured using behaviors or algorithms in the Policy mode.

7. The state mode allows context to change behavior as the state changes.

8. State conversion can be controlled by the state class or context class.

9. Using the status mode will usually cause a large number of classes to be added in the design.

10. The status class can be shared by multiple context instances.

[Design mode] Status 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.