Dmorley
July 18th, 2005, 05:32 AM
Hi,
This is an object design question - where do you think the best place is for the following functionality to be implemented.
Class 'Buyer'. Represents a product buyer.
Class 'Buyers'. Is a type-safe collection class of Buyer, inheriting the ReadOnlyCollectionBase class.
Both of these classes exist in my middle-tier business logic, which has access to the 'data access layer' that queries SQL Server. In my client GUI, i'm using the following code to load a combo box.
As you can see in the code, i've created a method that is part of the Buyers collection class that populates the collection.
oBuyers.Populate();
private void LoadBuyers(int BuyingDepartmentID)
{
Buyers oBuyers = new Buying.Buyers();
Utilities.ComboItem oCombo;
try
{
this.cboBuyers.Items.Clear();
// Create a blank item at the top of the list
oCombo = new Utilities.ComboItem("", -1);
this.cboBuyers.Items.Add(oCombo);
oBuyers.Populate(BuyingDepartmentID);
foreach (Buyer oBuyer in oBuyers)
{
oCombo = new Utilities.ComboItem(oBuyer.FullName, oBuyer.BuyerID);
this.cboBuyers.Items.Add(oCombo);
}
}
Should this Populate method be part of the Buyers class? Or should I implement this in another class that returns type 'Buyers'?
Any advice appreciated!
Thanks
This is an object design question - where do you think the best place is for the following functionality to be implemented.
Class 'Buyer'. Represents a product buyer.
Class 'Buyers'. Is a type-safe collection class of Buyer, inheriting the ReadOnlyCollectionBase class.
Both of these classes exist in my middle-tier business logic, which has access to the 'data access layer' that queries SQL Server. In my client GUI, i'm using the following code to load a combo box.
As you can see in the code, i've created a method that is part of the Buyers collection class that populates the collection.
oBuyers.Populate();
private void LoadBuyers(int BuyingDepartmentID)
{
Buyers oBuyers = new Buying.Buyers();
Utilities.ComboItem oCombo;
try
{
this.cboBuyers.Items.Clear();
// Create a blank item at the top of the list
oCombo = new Utilities.ComboItem("", -1);
this.cboBuyers.Items.Add(oCombo);
oBuyers.Populate(BuyingDepartmentID);
foreach (Buyer oBuyer in oBuyers)
{
oCombo = new Utilities.ComboItem(oBuyer.FullName, oBuyer.BuyerID);
this.cboBuyers.Items.Add(oCombo);
}
}
Should this Populate method be part of the Buyers class? Or should I implement this in another class that returns type 'Buyers'?
Any advice appreciated!
Thanks