(NET) NET (2016)

Facade in VB.NET

A single class that represents an entire subsystem

Return


Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. Facade pattern provides a simplified and uniform interface to a large subsystem of classes.







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



   1:      ' Facade Design Pattern.
   2:      ' See description in //www.vb-net.com/ProgramTheory/Facade.htm
   3:      Class MainApp
   4:          ' Entry point into console application.
   5:          Public Shared Sub Main()
   6:              Dim facade As New Facade()
   7:              facade.MethodA()
   8:              facade.MethodB()
   9:              ' Wait for user
  10:              Console.ReadKey()
  11:          End Sub
  12:      End Class
  13:   
  14:      ' The 'Subsystem ClassA' class
  15:      Class SubSystemOne
  16:          Public Sub MethodOne()
  17:              Console.WriteLine(" SubSystemOne Method")
  18:          End Sub
  19:      End Class
  20:   
  21:      ' The 'Subsystem ClassB' class
  22:      Class SubSystemTwo
  23:          Public Sub MethodTwo()
  24:              Console.WriteLine(" SubSystemTwo Method")
  25:          End Sub
  26:      End Class
  27:   
  28:      ' The 'Subsystem ClassC' class
  29:      Class SubSystemThree
  30:          Public Sub MethodThree()
  31:              Console.WriteLine(" SubSystemThree Method")
  32:          End Sub
  33:      End Class
  34:   
  35:      ' The 'Subsystem ClassD' class
  36:      Class SubSystemFour
  37:          Public Sub MethodFour()
  38:              Console.WriteLine(" SubSystemFour Method")
  39:          End Sub
  40:      End Class
  41:   
  42:      ' The 'Facade' class
  43:      Class Facade
  44:          Private _one As SubSystemOne
  45:          Private _two As SubSystemTwo
  46:          Private _three As SubSystemThree
  47:          Private _four As SubSystemFour
  48:          Public Sub New()
  49:              _one = New SubSystemOne()
  50:              _two = New SubSystemTwo()
  51:              _three = New SubSystemThree()
  52:              _four = New SubSystemFour()
  53:          End Sub
  54:          Public Sub MethodA()
  55:              Console.WriteLine(vbLf & "MethodA() ---- ")
  56:              _one.MethodOne()
  57:              _two.MethodTwo()
  58:              _four.MethodFour()
  59:          End Sub
  60:          Public Sub MethodB()
  61:              Console.WriteLine(vbLf & "MethodB() ---- ")
  62:              _two.MethodTwo()
  63:              _three.MethodThree()
  64:          End Sub
  65:      End Class




See also:
Creational Patterns Structural Patterns Behavioral Patterns


Theory context:



Comments ( )
Link to this page: //www.vb-net.com/ProgramTheory/Facade.htm
< THANKS ME>