(NET) NET (2016)

Brige in VB.NET

Separates an object’s interface from its implementation

Return


Decouple an abstraction from its implementation so that the two can vary independently. The implementation can evolve without changing clients which use the abstraction of the object.







Please download project with this source code from https://github.com/ViacheslavUKR/StandardDisignOopPattern



   1:      ' Bridge Design Pattern.
   2:      ' See description in //www.vb-net.com/ProgramTheory/Bridge.htm
   3:      Class MainApp
   4:          ' Entry point into console application.
   5:          Public Shared Sub Main()
   6:              Dim ab As Abstraction = New RefinedAbstraction()
   7:              ' Set implementation and call
   8:              ab.Implementor = New ConcreteImplementorA()
   9:              ab.Operation()
  10:              ' Change implemention and call
  11:              ab.Implementor = New ConcreteImplementorB()
  12:              ab.Operation()
  13:              ' Wait for user
  14:              Console.ReadKey()
  15:          End Sub
  16:      End Class
  17:   
  18:      ' The 'Abstraction' class
  19:      Class Abstraction
  20:          Protected _implementor As Implementor
  21:          ' Property
  22:          Public WriteOnly Property Implementor() As Implementor
  23:              Set(value As Implementor)
  24:                  _implementor = value
  25:              End Set
  26:          End Property
  27:          Public Overridable Sub Operation()
  28:              _implementor.Operation()
  29:          End Sub
  30:      End Class
  31:      ' The 'Implementor' abstract class
  32:      MustInherit Class Implementor
  33:          Public MustOverride Sub Operation()
  34:      End Class
  35:   
  36:      ' The 'RefinedAbstraction' class
  37:      Class RefinedAbstraction
  38:          Inherits Abstraction
  39:          Public Overrides Sub Operation()
  40:              _implementor.Operation()
  41:          End Sub
  42:      End Class
  43:   
  44:      ' The 'ConcreteImplementorA' class
  45:      Class ConcreteImplementorA
  46:          Inherits Implementor
  47:          Public Overrides Sub Operation()
  48:              Console.WriteLine("ConcreteImplementorA Operation")
  49:          End Sub
  50:      End Class
  51:   
  52:      ' The 'ConcreteImplementorB' class
  53:      Class ConcreteImplementorB
  54:          Inherits Implementor
  55:          Public Overrides Sub Operation()
  56:              Console.WriteLine("ConcreteImplementorB Operation")
  57:          End Sub
  58:      End Class




See also:
Creational Patterns Structural Patterns Behavioral Patterns

Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/ProgramTheory/Bridge.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>