I’m having a little trouble getting my head around the conceptual difference between an object and a class. I don’t really understand the distinction between the two in any programming language, but currently I’m working with Perl, and Moose, so I’d prefer an explanation using those things.
Cheers
There are lots of ‘a class is a blueprint, an object is something built from that blueprint’, but since you’ve asked for a specific example using Moose and Perl, I thought I’d provide one.
In this following example, we’re going have a class named ‘Hacker’. The class (like a blueprint) describes what hackers are (their attributes) and what they can do (their methods):
Now that we’ve got our Hacker class, we can start making Hacker objects:
This results in the following output:
If I want I can have as many Hacker objects as I like, but there’s still only one Hacker class that describes how all of these work.
All the best,
Paul