Object

An object is a specific instance created from a class. The class is the blueprint; the object is the thing built from it.

You can create as many objects as you need from the same class. Each one is independent — it has its own copy of the class’s data, separate from every other instance.

  ┌─────────────────┐
  │  class Player   │  ← blueprint (defined once)
  └────────┬────────┘
           │ instantiate
     ┌─────┴──────┐
     ▼            ▼
 ┌────────┐   ┌────────┐
 │ Alice  │   │  Bob   │  ← objects (created at runtime)
 │ score:3│   │ score:1│    each has its own data
 └────────┘   └────────┘

Class vs Object#

This distinction confuses almost every beginner. Here’s the clearest way to think about it:

  • The class is the definition. It exists in your code. It describes what an object will look like and what it can do. Defining a class doesn’t create anything you can use yet.
  • The object is the real thing. It exists at runtime, in memory. It has actual values, can call methods, and can be passed around the program.

A class is like the word “cake” in a recipe book. An object is an actual cake sitting on a table.

Creating an Object#

Creating an object from a class is called instantiation. The syntax varies by language:

Use the new keyword followed by the class name and parentheses.

Player player = new Player();
  • Player on the left is the type — the class this variable holds
  • player is the variable name
  • new Player() creates the object

Call the class name as if it were a function.

player = Player()

Python has no new keyword. Calling Player() creates the object and calls __init__ automatically.

Use the new keyword followed by the class name and parentheses.

const player = new Player();

Without new, calling Player() doesn’t create an object — it either throws an error or behaves unexpectedly.

Calling Methods on an Object#

Once you have an object, you call its methods using dot notation.

player.Greet()
  │      └── method name
  └── object (the instance, not the class)

The method runs in the context of that specific object. If it reads or changes any data, it reads or changes that object’s data — not another instance’s.

Common Mistakes#

Confusing the class name with the object variable After writing Player player = new Player(), the class is Player and the object is player. Calling Player.Greet() instead of player.Greet() is a compile error for non-static methods — always call methods on the instance.

Forgetting to instantiate before calling a method Declaring a variable isn’t the same as creating an object. In C#, Player player; declares a variable that holds nothing — calling player.Greet() throws a NullReferenceException. You must use new to create the object first.

Assuming two variables point to different objects when they don’t In most languages, assigning one object variable to another doesn’t create a copy — both variables point to the same object. Changes through one variable are visible through the other.

Resources#