3 ms·
> I haven't seen a lot of places where inheritance was the best idea. Interfaces yes, inheritance no. I like to use interfaces to expose the public side of thi
by magicalhippo 3y ago
> I haven't seen a lot of places where inheritance was the best idea. Interfaces yes, inheritance no.
I like to use interfaces to expose the public side of things, but I find inheritance can be really powerful in terms of code-reuse for implementing those interfaces.
Of course if you got a language that makes encapsulation very smooth then inheritance might not be needed, but otherwise I find it can really cut down on code re-use and boilerplate to have a base class for certain interfaces.
Of course, since the interface is the public bit, if the base class is not a good fit for a certain implementation there's no requirement to use the common base class. So you use it when it makes sense.