Here is my specific scenario with an interface and its implementation:
IPerson {string Name;} American : IPerson {string Name;} Asian : IPerson {string Name;} European : IPerson {string Name;} People = new List<IPerson>();
When I go to the People list, I need to make a distinction between American, Asian and European, and they can use the same interface. Is it good to use additional interfaces (IAmerican, IAsian, IEuropean) that all implement IPerson and use them in order to distinguish between the implementation class, for example:
IAmerican : IPerson {} IAsian : IPerson {} IEuropean : IPerson {} American : IAmerican {string Name;} Asian : IAsian {string Name;} European : IEuropean {string Name;} People = new List<IPerson>(); People.Add(new American()); People.Add(new Asian()); People.Add(new European()); var americans = People.OfType<IAmerican>();
The new interfaces are not very useful, but for separating objects. Is this a good approach, or should I implement some type property in IPerson in order to distinguish its implementation?
source share