Python @ DjangoSpin

PyPro #81 Facade Design Pattern

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Facade Design Pattern in Python

Facade Design Pattern in Python

Write a Python program to implement Facade Design Pattern.

Facade

class ProcessingUnit:
    '''Subsystem #1'''
    def process(self):
            print("Processing...")
 
class DisplayUnit:
    '''Subsystem #2'''
    def display(self):
            print("Displaying...")
 
class Memory:
    '''Subsystem #3'''
    def ioOperation(self):
            print("Reading and writing to memory...")
 
class Computer:
    '''Facade'''
    def __init__(self):
        self.processingUnit = ProcessingUnit()
        self.displayUnit = DisplayUnit()
        self.memory = Memory()
 
    def bootUp(self):
        self.processingUnit.process()
        self.memory.ioOperation()
        self.displayUnit.display()
 
computer = Computer()
computer.bootUp()

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply