Bridge mode case Eight commandments "reincarnation" story

Source: Internet
Author: User

From the point of view of bridge mode, this section discusses the story of the reincarnation of the Grand Admiral of the Journey to the pig.

If there is a soul, it should be the abstract role, while the body is the realization of the role. The body provides the realization of the function of the soul, just as the concrete Java classes provide implementations for abstract Java classes.

The UML class diagram of the reincarnation system:

As can be seen, the "reincarnation" mechanism divides the world into two hierarchical structures: the first hierarchy is the "soul" hierarchy, and the second hierarchy is the "body" hierarchy. The former is the equivalent of abstraction, the latter equivalent to the realization. By delegating the function, the creature invokes the function of the body object so that the creature can choose its own body dynamically.

In the UML class diagram above, the correspondence between the roles and the role of the bridge pattern is as follows:

  • Abstract role: "Soul" is an abstract class that gives all the spiritual definitions of humans, beasts, monsters, and gods, and regulates their methods and attributes.
  • Correcting abstract roles: In the case of the Eight commandments, the soul of the Marshal is the abstract role of the eight precepts, just as the monks, beasts, birds, and 魑魅魍魉 are their abstract roles. These abstract roles are specific abstract roles, in other words, they are materialized roles under the abstract character "soul", but they are also abstract characters of the body such as "man", "Fish", "bird".
  • Realization of the role: this role is the "body". This abstract class specification implements specific roles to standardize the methods and properties that should be implemented for specific implementations of the role
  • Specific implementation of the role: this is a variety of physical shell, including people, fish, birds and so on.

Bridge mode case Eight commandments "reincarnation" story

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.