Should a property be in an abstract class if not directly used

by DasDave   Last Updated September 19, 2018 09:05 AM

I have an abstract base class that is inherited by several different other types. They were all using a type injected into their constructor. So I moved this property in to the abstract base class. The base class doesn't use it in any of it's methods. It is used in every single one of the inheriting classes though. Should this be in the base class or declared separately in the other classes?

public abstract class FooBase
{
    protected TypeA a {get;}

    protected FooBase(TypeA a)
    {
        this.a = a;
    }
}

public class FooA : FooBase
{
    public FooA(TypeA a) : base (a)
    {
    }

    public void SomeMethod()
    {
        a.DoSomething();
    }
}


Related Questions


Inheritance from children to parents?

Updated May 30, 2016 08:02 AM