Multiple classes defining same props vs inherit from base class
Say I have multiple service classes, here's two as an example:
Instead of repeating the two private properties and the ctor on every service class, would it be acceptable to create a base class which the service classes inherit from? E.g:
I'm just approaching this from a DRY point of view. Technically I'm still repeating myself with the ctor in every service class, but it just seems cleaner? Some guidance would be much appreciated
5 Replies
in any case, make sure the base class is abstract
you can make the properties protected if they aren't intended for use outside of the inherited types
So what I'm gathering is that it's an acceptable way to go, just need to tweak a couple of things?
yes
Thanks fellas