Built from the drawing

Objects as Houses

The analogy

An object is an actual house standing on an actual street. Two houses from the same drawing can be painted different colours and hold different families โ€” changing the curtains in one does not change the other. Each object keeps its own copy of the details.

Visualizer

Two houses, separate lives

step 1 / 4
class House
colour: string
windows: number
address: string
the drawing โ€” nobody lives here
house1
colour: white
๐Ÿ 
house2
colour: white
๐Ÿ 

Two houses, same drawing, identical so far. Both white.

a = House("white")
b = House("white")

a.colour = "ochre"

print(a.colour)  # "ochre"
print(b.colour)  # "white"  <- untouched
print(a is b)    # False โ€” two objects
Check yourself

You paint house A blue. What colour is house B?