Bridging Mode: Separates the abstract Part of the system from its implementation part so that they can change independently.
BecauseThe target system has multiple levels of classification., Each category will have a variety of changes, so we can separate them from multiple angles and let themIndependent changes,Reduce coupling between them.
# Encoding = UTF-8 ## by Panda # Bridge Mode def printinfo (Info): Print Unicode (Info, 'utf-8 '). encode ('gbk') # Abstract class: mobile phone brand class handsetbrand (): soft = none def sethandsetsoft (self, soft): Self. soft = soft def run (Self): pass # specific abstract class: mobile phone brand 1 class handsetbrand1 (handsetbrand): def run (Self): printinfo ('mobile phone brand 1: ') self. soft. run () # specific abstract class: mobile phone brand 2 class handsetbrand2 (handsetbrand): def run (Self): printinfo ('mobile phone brand 2: ') self. soft. run () # function class: mobile software class handsetsoft (): def run (Self): pass # specific function class: Game class handsetgame (handsetsoft): def run (Self ): printinfo ('running a mobile game') # function class: Address Book class handsetaddresslist (handsetsoft): def run (Self): printinfo ('running a mobile phone address') def clientui (): h1 = handsetbrand1 () extract (handsetaddresslist () h1.run () h1.sethandsetsoft (handsetgame () h1.run () H2 = handsetbrand2 () h2.sethandsetsoft (handsetaddresslist () h2.run () h2.sethandsetsoft (handsetgame () h2.run () returnif _ name _ = '_ main _': clientui ();
Class Diagram: