T
Tony Johansson
Hello
I have a class hierarcy in this way.
The super class is an abstract class Animal and derived fom that is Bird,
Mammal, Insect, Marine and Reptile all abstract.
Derived from these Bird, Mammal, Insect, Marine and Reptile is the specific
classes like cat, dog, snake, gnat, stoneFish and the like.
Now if I want to add information for each category(Bird, Mammal, Insect,
Marine and Reptile ) for example wingspan for the bird category and number
of teeth for the mammal and so on where is it most suitable to place such
informatiion.
I have done in the following way. Place this abstract CategoryInfo method in
the abstract animal class and then implement this CategoryInfo method in
each of the five animal category classes Bird, Mammal, Insect, Marine and
Reptile
public abstract string CategoryInfo { get; set; }
But it's also possible to place this CategoryInfo direct in the animal
class. So does anyone have an opinoin which is the best way to do ?
Can you also motivate why it best to place it there ?
//Tony
I have a class hierarcy in this way.
The super class is an abstract class Animal and derived fom that is Bird,
Mammal, Insect, Marine and Reptile all abstract.
Derived from these Bird, Mammal, Insect, Marine and Reptile is the specific
classes like cat, dog, snake, gnat, stoneFish and the like.
Now if I want to add information for each category(Bird, Mammal, Insect,
Marine and Reptile ) for example wingspan for the bird category and number
of teeth for the mammal and so on where is it most suitable to place such
informatiion.
I have done in the following way. Place this abstract CategoryInfo method in
the abstract animal class and then implement this CategoryInfo method in
each of the five animal category classes Bird, Mammal, Insect, Marine and
Reptile
public abstract string CategoryInfo { get; set; }
But it's also possible to place this CategoryInfo direct in the animal
class. So does anyone have an opinoin which is the best way to do ?
Can you also motivate why it best to place it there ?
//Tony