Through volunteering and organizing events to introduce people to programming, I’ve heard lots of great ways to explain difficult programming concepts. Sometimes the questions you’ll receive as a volunteer will rattle your understanding of a concept, and by the time you’ve explained it, you’ve learned something yourself. Here’s a short list of some of the more helpful ones I’ve used and heard. Hopefully they will help you explain something or learn something yourself!
1: A class is like a spaceship blueprint; an instance of the class is the actual spaceship.
A class is like a spaceship blueprint. It is not a spaceship. It tells you the general components of a spaceship and some of the things it can do - size, name, engines, captain, crew, “go fast”, “enable shields,” etc. The instance, or object, is the actual built spaceship. It has a name (“USS Enterprise”), a captain (“Jean-Luc Picard”), and everything else fleshed out. You can actually ride in the spaceship instance/object. The spaceship instance/object can actually fly. It exists. The class file is a dead document describing a thing. The instance/object is the physical, built thing.
I thought that was great and have been using it ever since. Thanks, Nizar!
2: The database is like a giant, intelligent spreadsheet.
Laura Lindeman says that once she realized the mysterious database was just a place to store bits of data in an organized way, it helped her mental concept of the database come into focus.
Now, she knows and we know that it’s not quite that simple under the hood, but for someone dealing with databases for the first time, it’s a sufficient, familiar example that allows some clarity about where the data from the web pages is going and how it’s being accessed.
3: MVC is like ordering a pizza from a restaurant.
This one combines some of my favorite things, MVC and 🍕, so I loved hearing and using this one. All credit to Blithe Rocher here.
Essentially: the model is the description of the pizza on the menu (not unlike a blueprint for making a pizza (#1)). The controller is the restaurant, taking your order (with any modifications to the toppings) and preparing the pizza. The view is what they deliver to you, delicious and beautiful, with each topping perfectly in place.
If you’ve heard or created great similes yourself, please send them my way.