Object oriented programming has a few core concepts, which if you know them, will help you out tremendously!
The first is the concept of classes and objects, which is strangely overdone on the internet (and books for that matter).
The concept is extremely simple and maybe people over explain it. That’s probably the root of the confusion but I’m here to save the day!
Ready for it? Here you go:
- A Class is a blueprint.
- An Object is the thing made from that blueprint.
Yeah. Really. It’s that simple.
That means that there is generally one class but there can be many, many objects (as many as you like!).
In programming terms a class might look like this (Swift language here but could be any language):
var speed = 50
func PaintCar ()
func FloorIt ()
So a class can have properties, functions and anything else common to whatever language you’re using (generally speaking).
Now for a bunch of objects made from that class:
var ferrari = Car()
var ford = Car()
var nissan = Car()
Yeah, 3 objects all made from the same blueprint. Now I know that Ferrari, Ford and Nissan aren’t the same (Nissan’s better) but you get my point.
One class is used to create multiple objects.
Does that clear it up for you? If not, then please do comment!