Understanding Bridge Pattern using .NET
page 6 of 13
by David Simmonds
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 46991/ 171


Internally it aggregates a control which the user will manipulate in order to produce a range of scores.  It also keeps an acquaintance-reference to an Implementor (a renderer).  The UpdateScoreValue() function will call the render method on the Renderer and pass to it the score which it should render at the same time.

Listing 1

' Equivalent to Abstraction in the Bridge pattern
Public MustInherit Class Evaluation
  Protected m_RenderingDevice As Implementors.RatingRenderer
  ' Equivalent to Operation in the pattern
  Public MustOverride Function UpdateScoreValue()
  Public Property RatingRenderDevice() As 
                           Implementors.RatingRenderer         …
  End Property
End Class
' Equivalent to Refined Abstraction in the Bridge pattern
Public Class VerbalEvaluation   
       Inherits Evaluation
  Dim ChoiceList As ListBox
  Dim ChoiceString As String
  Dim EquivalentScore As Integer
  Public Sub New(ByVal ControllerListBox As ListBox)
     ChoiceList = ControllerListBox
  End Sub
  ' Equivalent to Operation in the pattern
  Public Overrides Function UpdateScoreValue()                
     ChoiceString = ChoiceList.SelectedItem
     ' Translate the specific selections in the list box to 
     'a standard language - the score
     Select Case LCase(ChoiceString)
         Case "poor"
              EquivalentScore = 1
         Case "fair"
              EquivalentScore = 2
        Case "excellent"
             EquivalentScore = 5
     End Select
     ' The payload statement – uses the acquaintance implementor
     '     to implement the score
     End Function
End Class

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-28 9:53:20 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search