Say I have a parent class "Fruit" and a bunch of child classes representing different types of fruit.
I have a List<Fruit> to contain all my fruit.
In the UI class would I simply ask the user what type they want to create, get all the data in a string array then pass it to the CP class? The CP class would do input validation then pass it to the BL which for inserting into a database it would just pass it to the DA class.
Would the DA layer have different methods like, "AddBanana()", "AddApple()", etc? Or one "Add()" method which it would somehow be able to figure out what type it is to instantiate the proper fruit object and put the information in it then add it to the List.
Or would the BL layer instantiate the proper fruit and fill in the information and pass it to the DA class which would just take a Fruit object as a parameter and add it?
I'm quite confused on exactly the flow and role of all of these layers and what each layer is allowed to know about. I imagine its going to get much more confusing when I get into updating, querying and deleting.
Here's a sample code for a DA layer, what am I doing wrong?
public string Lookup(Types type)
{
List<Parents> search = new List<Parent>();
switch (type)
{
case Types.TypeOne:
{
search = ParentDataBase.FindAll( delegate(Child1 findChild) {
return findChild is ChildOne; } );
}
break;
case Types.TypeTwo:
{
search = ParentDataBase.FindAll( delegate(Parents findChild) {
return findChild is ChildTwo; } );
}
break;
case Types.TypeThree:
{
search = ParentDataBase.FindAll( delegate(Parent findChild) {
return findChild is ChildThree; } );
}
break;
}
string results = "";
foreach (Parent x in search)
{
results += t.ToString();
}
return results;

New Topic/Question
Reply




MultiQuote




|