Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. how to comprehend the definition of Bridge pattern by Gof?

how to comprehend the definition of Bridge pattern by Gof?

Scheduled Pinned Locked Moved Design and Architecture
tutorialquestionregexoop
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zxjun84
    wrote on last edited by
    #1

    1.There is an object varying for two dimensionality which change commonly.we can decouple the two dimensionality ,so they can vary indepently and not mutually affect.For example ,when we want to draw a picture through pen.Pen may have different size like big pen or small pen.It also has different color like red or green.Apperently the pen as an object used to draw will vary through different matching of size and color.Now,we can utilize a "bridge" to connect the CSize class and CColor class.is it that? 1 abstract class Brush 2 { 3 protected Color c; 4 public abstract void Paint(); 5 6 public void SetColor(Color c) 7 { this.c = c; } 8 } 1 class BigBrush : Brush 2 { 3 public override void Paint() 4 { Console.WriteLine("Using big brush and color {0} painting", c.color); } 5 } 1 class SmallBrush : Brush 2 { 3 public override void Paint() 4 { Console.WriteLine("Using small brush and color {0} painting", c.color); } 5 } 1 class Color 2 { 3 public string color; 4 } 1 class Red : Color 2 { 3 public Red() 4 { this.color = "red"; } 5 } 1 class Green : Color 2 { 3 public Green() 4 { this.color = "green"; } 5 } 1 class Blue : Color 2 { 3 public Blue() 4 { this.color = "blue"; } 5 } 1 class Program 2 { 3 public static void Main() 4 { 5 Brush b = new BigBrush(); 6 b.SetColor(new Red()); 7 b.Paint(); 8 b.SetColor(new Blue()); 9 b.Paint(); 10 b.SetColor(new Green()); 11 b.Paint(); 12 13 b = new SmallBrush(); 14 b.SetColor(new Red()); 15 b.Paint(); 16 b.SetColor(new Blue()); 17 b.Paint(); 18 b.SetColor(new Green()); 19 b.Paint(); 20 } 2.Gof defines the bridge pattern as Decouple an abstraction from its implementation so that the two can vary independently. question: According to item 1 ,how to comprehend the definition of Bridge pattern by Gof ?Especially, what does the "abstraction" and "implementation " Gof stand for?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups