Python design mode (9)-Appearance mode

Source: Internet
Author: User

#/* Appearance mode: Provides a unified interface for external calls and extracts the methods needed in other classes
# * out, called by the skin class. The skin class is then instantiated in the call segment to indirectly invoke the required
# * method. This approach is similar to the proxy model. However, according to the Dimitri Law, the agent
# * Patterns should be proxied as much as possible for a single object. And the appearance pattern is more like extracting from many classes.
# * A useful method to combine into a new class */

Class Invoke1:
def methon1 (self):
print ' Call 1 '


Class Invoke2:
def methon2 (self):
print ' Call 2 '


Class Invoke3:
def methon3 (self):
print ' Call 3 '


Class FACDE:
def __init__ (self):
SELF.A = Invoke1 ()
self.b = Invoke2 ()
SELF.C = Invoke3 ()

def unit1 (self):
Self.a.methon1 ()
Self.b.methon2 ()
Self.c.methon3 ()

def unit2 (self):
Self.a.methon1 ()
Self.b.methon2 ()


if __name__ = = "__main__":
FACDE = FACDE ()
Facde.unit1 ()
Facde.unit2 ()

Python design mode (9)-Appearance mode

Related Article

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.