We have a relatively big class. One of my colleagues thinks we must split this class into a base & child class to make it smaller and cleaner.
On the other hand, I believe when we know this parent will always have only just this one child, inheritance isn't an appropriate solution.
So imagine these classes:
public class Foo : Bar, IFoo
{
public Task DoSomething(SomeData someDate)
{
}
// Some other public methods that are exposed in IFoo interface
}
public abstract class Bar
{
protected readonly ISomeInjectedService _someInjectedService;
public Bar(ISomeInjectedService someInjectedService)
{
_someInjectedService=someInjectedService;
}
// Some other private or protected methods
}
Or this class:
public class Foo : IFoo
{
private readonly ISomeInjectedService _someInjectedService;
public Foo(ISomeInjectedService someInjectedService)
{
_someInjectedService=someInjectedService;
}
// Some other private methods
public Task DoSomething(SomeData someDate)
{
}
// Some other public methods that are exposed in IFoo interface
}
The important point is, this new base class will never have another child. The question is: Is inheritance usage, justified here?