liveBook · Manning

Object-oriented programming

As explained in The Well-Grounded Python Developer: How the pros use Python and Flask

Object-oriented programming is a programming paradigm that organizes software around objects containing state and behavior.

Object-oriented programming organizes state and the functionality that acts on it into objects. This reduces the coordination problem that appears when the same functions must work with multiple, distinct stateful contexts. section 4.0 section 4.1

The central ideas fit together as a practical design vocabulary:

  • A class defines the structure, data, and functionality of an object. section 4.1 section 4.3
  • An instance is a concrete realization of a class, with behavior that operates on its state. section 4.3
  • Inheritance reuses attributes and features from a parent class, while composition adds attributes or functionality without forcing an awkward hierarchy. section 4.3

From separate data to behaving objects

Suppose several functions must process different stateful data contexts. Passing the data through consistent function signatures can work, but keeping each context connected to the right functions becomes harder. A class instead defines an object whose data and methods belong together. The class is like a cookie cutter; each instance is a concrete cookie with the defined structure and behavior. section 4.0 section 4.3

In Python, OOP is one option among several programming styles. It works alongside structured, procedural, functional, and event-driven approaches, allowing the design to match the problem rather than forcing every program into one model. section 1.3.1

How The Well-Grounded Python Developer: How the pros use Python and Flask covers it

How deep it goes
Explains encapsulation, classes, instances, inheritance, and composition as design mechanisms for reusable objects.
Examples
Uses stateful function calls, collection objects, and a cookie-cutter analogy to distinguish classes from instances.
What it assumes
Builds on function signatures, stateful data, collection objects, and basic Python programming while clarifying object-based organization.
What you can do after
Apply it by designing classes that combine data and methods, reuse features through inheritance, and extend designs through composition.
How it connects
Connects objects with functions, state, classes, inheritance, composition, code reuse, and the DRY principle.

Also explained in

Compare how 9 books explain object-oriented programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Python Developer: How the pros use Python and Flask. The section links point to the parts of the book it draws on.