Objects (Classes) Explained In Very Simple Terms
One of the most common questions on Yahoo! Answers is how classes or objects, or the parts of a class / object, such as properties, methods and events, work.
Here’s a gross simplification of how classes and objects work. Most of this is lifted from a previous blog entry, Interpreting A C# Class Code Structure.
Classes / Objects
A class or object is a way of combining all sorts of data that relates to a single thing in one place, and a way of associating functions with that data. (For most intents and purposes, classes and objects are the same thing. Whenever I use the term class, I also mean object; whenever I use object, I also mean class. More on that in a moment.)
For example, you can think of a human as a class.
In the human class, you are an instance. For example, you might think that God decided to run this code when you were born:
Dim you As New HumanBeing()
What He did was create a variable, named you, and set the value of that variable to be an instance of the HumanBeing object. An instance is the actual use of an object. The object is the mold; the instance is the actual thing you made from the mold.
(Most programmers use the term class when they are speaking about an instance, and object when they are talking in general terms, so that’s the real difference between class and object. However, you can generally use the two terms interchangeably when discussing a specific programming issue.)
Continue reading ‘Objects (Classes) Explained In Very Simple Terms’ »