I have a class called Person with a property that specifies if there is a Grid object attached. There are 3 types of grid objects. 2 of them will have the exact same properties and the 3rd will have completely different ones.
What is the best type of abstraction to use so the Grid property in the Person class can accept all 3 types? By that I mean should I use an abstract class, base class, or interface? Or should I look into generics?
My thoughts are to use an abstract class, this way I can implement the properties and not have redundant code in the 2 classes that share the same properties. It will also force anyone adding new grid types to create a new class that is derived from it. I need this last part because I need to check which type of Grid object it is, using reflection, so I can add some conditional logic.
It just feels odd that the 3rd grid type will have these unnecessary properties.
If the 3rd grid type has totally different properties then how can Person accept them all in the same way? You can only ‘abstract’ commonalities. You are passing 2 different things to Person – so I wouldn’t try to abstract them just because they are both grids.