Instances

Like Coke, an instance is the real thing. Whereas the PacMan class is just the idea of what a real PacMan would be, an instance of the PacMan class is a real PacMan. It can move, it can chomp, it can jump (maybe?)—it’s the real deal. The reason to keep classes and instances separate is so you can create multiple instances of a single class (for example, a game of Pac-Man has multiple Ghosts). Classes and instances keep your code organized and easy to understand.

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.