Interfaces can be confusing for beginner programmers, but I think I have the right analogy to explain them in simple terms.
Imagine with me for a moment, that you were born into a wealthy family, so wealthy that you need not do very much for yourself, and especially not be bothered with transportation. You even hired the best chauffeur that can handle any vehicle.
The only thing required of you is selecting a vehicle, everything else will be taken care of. If you're to be transported somewhere, you'll need that vehicle to have at least 3 functionalities:
- A place for the driver or operator.
- A place for you to sit.
- some way to move.
There are obviously other things, but they don't concern you. You just need the basics. Does a car fit this description? Yes of course, you have both seats, and it can travel along a road or path. Does a commercial airplane fit the description? Yes again, even though there might be extra seats, it can take you somewhere. even though it does it differently than a car would. A bench would not satisfy the requirements, even though it has 2 seats, it goes nowhere.
This is what an interface calls for, an object that can do certain things. It doesn't care how they get done, as long as the user (or the controller in an MVC app) says "GO" it knows it can go.
Just a quick analogy today. Have a great weekend everybody!
Top comments (2)
Why is your middle initial "A" when your name is Seth "Demystifies-Interfaces" Burleson?
LOL I'd talked to someone about this in a breakout room friday and realized it would probably make a great blog post. Glad its helpful!