© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
9 replies
Irae

❔ Creating a base abstract class to ensure a set of derived classes receive similar dependencies?

Hi, working on creating a class library and I have a set of classes, let's call them PlainPizza, PepperoniPizza and SausagePizza. These three need to have injected into them a set of similar dependencies by the DI container however beyond that they share no common methods.

Would it be advisable to have them inherit from a base abstract class that injects those dependencies while each derived class has its own interface that it implements such that unit testing is made easier?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Mocking derived class with abstract base class
C#CC# / help
4y ago
❔ base class/abstract for record
C#CC# / help
3y ago
❔ Default implementation of a `static abstract` base interface member in derived interface
C#CC# / help
3y ago
Use reflection to get type of abstract base class [Answered]
C#CC# / help
4y ago