A
Adrian
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.Collections;
namespace trial_seven
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Customers customers = new Customers("Chicago");
customers.Data = new CustomersData();
customers.show();
customers.show();
}
class CustomersBase
{
private DataObject dataObject;
protected string group;
public CustomersBase(string group)
{
this.group = group;
}
public DataObject Data
{
set
{
dataObject = value;
}
get
{
return dataObject;
}
}
public virtual void show()
{
dataObject.ShowRecord();
}
}
class Customers:CustomersBase
{
public Customers (string group):base(group)
{
}
}
abstract class DataObject
{
public abstract void ShowRecord();
}
class CustomersDataataObject
{
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.WriteLine(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.Collections;
namespace trial_seven
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Customers customers = new Customers("Chicago");
customers.Data = new CustomersData();
customers.show();
customers.show();
}
class CustomersBase
{
private DataObject dataObject;
protected string group;
public CustomersBase(string group)
{
this.group = group;
}
public DataObject Data
{
set
{
dataObject = value;
}
get
{
return dataObject;
}
}
public virtual void show()
{
dataObject.ShowRecord();
}
}
class Customers:CustomersBase
{
public Customers (string group):base(group)
{
}
}
abstract class DataObject
{
public abstract void ShowRecord();
}
class CustomersDataataObject
{
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.WriteLine(customers[current++]);
}
}
}
}