What’s the difference between an Abstract class and an Interface? Radical.
A common misunderstanding and a source of confusion.
I’m a developer, you are a designer. That’s fine. We should both be able to make posts in Forrst. We are Person(s) after all.
An interface is all about behaviour. What can both a Developer and a Designer do in Forrst? That’s right, make posts. That’s our common behaviour here in Forrst, what makes us interchangeable.
Now I will be most likely writing about Java and you will be showcasing your million dollar design, but we both have to go through the same process of writing our post.
- Specify a title
- Paste some code
- Enter a description
- Put some tags
Now that’s a pretty nifty algorithm that we both have to go through to write a post and that’s what a base class is good at. Encapsulating common code.
However, since we won’t be writing the same stuff anyway though (title, code, description, tags), it’s destined to be abstract.
A follow up post titled Why I don’t drive a Porsche tries to put the final nail in the coffin on when/how to use an interface compared to an abstract class
Disclaimer: Another trivial example, don’t put that in production code please.
Special thanks: @sugarenia for the designer’s code