When to extend a normal class?

Posted 4 years ago by itstrueimryan

So I was watching the SOLID principles video series and a lot of it is about coding to an interface (or 3). I'm just wondering, when would I extend something other than an interface? I understand using abstract classes, especially when conforming to the Template pattern and in general when you need a defined implementation of one or two methods shared amongst all of the sub classes. But what about a normal class?

class Car { bla bla bla }

class Honda extends Car {}

class Toyota extends Car {}

In what situation would Car not be an interface (or an abstract)? Why would it ever be a normal class? I can see if you have grandchild classes...at which point the classes in the middle have to be regular classes, but is this even a situation that comes up? I'm just trying to think about all the different scenarios, and it's a bit overwhelming, especially after watching all of the SOLID videos at once. Could use some clarification. Thanks :D

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.