Is this unnecessary polymorphism

Say we have a base class

public class Equipment
{
    public string Name { get; set; }
    public int Year { get; set; }
}

My employee made 4 different classes. Each of these classes does not introduce any new property, but they all inherit directly from the base class. For instance:

public class Tow : Equipment
public class Truck : Equipment
public class Trailer : Equipment

There is a new file for each of these classes.

I personally think this is overkill, especially because this derived class does not introduce any new property. And now you need to do boxing / unboxing.

I think a much simpler solution is to have a base class of equipment, but there is a property that says "Equipment.EquipmentType" that contains Truck, Trailer, Tow, etc. So these are not 4 different classes.

What do you guys think is the best approach here?

+4

Source: https://habr.com/ru/post/1660435/


All Articles