Skip to content
BENIBIX Learn

Object (Programming)

Development🧭 Programming ParadigmsObject-Oriented Programming

Also known as Object, Instance, Class Instance

One real thing made from a class, with its own values. Also called an instance.

Think of it like

Think of it like one cookie from the cutter. It has the same shape as the others, but its own sprinkles.

Example

Jack makes two Dog objects, Rex and Bo. Giving Rex a new name leaves Bo exactly as he was.

Why it matters

Objects are what a program actually works with. The class only describes them.

Definition

An object is one real thing made from a class, holding its own values. Two dog objects made from the same Dog class can have different names and ages. An object is also called an instance of its class. You reach its data and actions with a dot, like rex.name or rex.speak(). Changing one object does not change the others.

Example code

python
>>> rex = Dog("Rex")
>>> rex.name
'Rex'
Make one dog from the Dog class, then read its name.

Common mistake

Expecting a change to one object to show up in another. Each holds its own copy of the data.

Key takeaways

  1. 1
    Made from a class. Also called an instance.
  2. 2
    Its own values. Separate from the others.
  3. 3
    Use a dot. rex.name, rex.speak().

Compare