03. What is a Class?

Quite simply, an Object is an instance of a Class. In order to understand this better, consider a set of architectural blueprints. If we were to build two houses from the same blueprint, those two houses would be considered instances of the blueprint. They could look completely different on the outside and be in completely different locations but structurally they’re made from the same plan. That’s exactly the relationship between Classes and Objects.

Our Card Class doesn’t actually have a suit or a card value, it simply provides a structure for how a Card should look and what it can do.

So in regard to terminolgy we now have some important jargon to take in:

  • Class: The blueprint for an Object
  • Object: The instantiation of a Class
  • Fields: These are the variables and constants inside a Class
  • Methods: These are the functions or sub-routines inside a class
  • State: When an Object has values in it’s fields, that object has a state
  • Behaviour: The actions that an Object can take via it’s methods
  • Constructor: This is a method that defines the state of an Object

Most of those probably seem pretty intuitive except perhaps the Constructor. I will clarify this later in the tutorial, at this stage just try to gain a little familiarity with some of the jargon you’re now going to see used a fair bit!

Leave a Comment

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>