The code below was taken from an example.
All the "noise" in the example was thrown out.
This is supposedly according to the bridge
pattern. What in the code (which lines)
represent the bridge pattern (make this code
to be according to the bridge pattern),
and what is the advantage of employing the
bridge pattern? It seems "l'art pour l'art" to me.
Adrian
using System.Collecti ons;
namespace trial_seven
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Customers customers = new Customers("Chic ago");
customers.Data = new CustomersData() ;
customers.show( );
customers.show( );
}
class CustomersBase
{
private DataObject dataObject;
protected string group;
public CustomersBase(s tring group)
{
this.group = group;
}
public DataObject Data
{
set
{
dataObject = value;
}
get
{
return dataObject;
}
}
public virtual void show()
{
dataObject.Show Record();
}
}
class Customers:Custo mersBase
{
public Customers (string group):base(gro up)
{
}
}
abstract class DataObject
{
public abstract void ShowRecord();
}
class CustomersData:D ataObject
{
private ArrayList customers = new ArrayList();
private static int current = 0;
public CustomersData()
{
customers.Add(" Jim Jones");
customers.Add(" Frank Rapper");
}
public override void ShowRecord()
{
Console.WriteLi ne(customers[current++]);
}
}
}
}
All the "noise" in the example was thrown out.
This is supposedly according to the bridge
pattern. What in the code (which lines)
represent the bridge pattern (make this code
to be according to the bridge pattern),
and what is the advantage of employing the
bridge pattern? It seems "l'art pour l'art" to me.
Adrian
using System.Collecti ons;
namespace trial_seven
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Customers customers = new Customers("Chic ago");
customers.Data = new CustomersData() ;
customers.show( );
customers.show( );
}
class CustomersBase
{
private DataObject dataObject;
protected string group;
public CustomersBase(s tring group)
{
this.group = group;
}
public DataObject Data
{
set
{
dataObject = value;
}
get
{
return dataObject;
}
}
public virtual void show()
{
dataObject.Show Record();
}
}
class Customers:Custo mersBase
{
public Customers (string group):base(gro up)
{
}
}
abstract class DataObject
{
public abstract void ShowRecord();
}
class CustomersData:D ataObject
{
private ArrayList customers = new ArrayList();
private static int current = 0;
public CustomersData()
{
customers.Add(" Jim Jones");
customers.Add(" Frank Rapper");
}
public override void ShowRecord()
{
Console.WriteLi ne(customers[current++]);
}
}
}
}
Comment