Mr. Grummel Get the app
← All notes
LEARNING 5 MIN READ DRAFT — JANUARY 2028

The programming style that treats data and the code that touches it as one bundle

Object-oriented programming bundles data with the specific functions that operate on it into a single object, meant to keep a large codebase organised by grouping related behaviour where its data actually lives.

Object-oriented programming organises code around objects, bundled units that combine data together with the specific functions, called methods, that are actually meant to operate on that data, rather than keeping data and the functions that act on it as separate, loosely connected pieces scattered through a program. Three core ideas work together to make that bundling useful: encapsulation, which hides an object's internal data behind a controlled interface; inheritance, which lets a new object type reuse and extend an existing one; and polymorphism, which lets different object types respond to the same instruction in their own appropriate way.

Encapsulation keeps an object's internal data protected behind a defined interface

Encapsulation means an object's internal data isn't directly, freely accessible from outside; other code has to go through the object's own defined methods to read or change that data, rather than reaching in and modifying it directly. This matters because it lets an object enforce its own internal rules, preventing a bank account object's balance from being set to an invalid value, say, and it means the object's internal implementation can be changed later without breaking other code, as long as its external interface, the methods other code actually calls, stays the same.

Inheritance and polymorphism let related object types share and specialise behaviour

Inheritance lets a new object type be defined as an extension of an existing one, reusing its data structure and methods while adding or overriding specific behaviour, which avoids duplicating the same code across several closely related object types. Polymorphism then lets code written to work with a general object type automatically work correctly with any more specific type built through inheritance, calling the same named method on genuinely different object types and getting each type's own appropriate behaviour in response. Together, these three ideas are meant to keep a large, growing codebase organised, with related data and behaviour grouped together rather than spread out and duplicated across the program.

Object-oriented programming bundles data together with the specific functions that operate on it into a single unit called an object, and that bundling, encapsulation, inheritance and polymorphism together, is meant to keep a large codebase organised by grouping related behaviour where the data it acts on actually lives.

What we're still unsure about

That encapsulation, inheritance and polymorphism provide real, practical tools for organising related data and behaviour together is well established, confirmed by decades of widespread use across major programming languages and large software systems. What's more genuinely a matter of ongoing debate among software engineers is exactly how much a codebase should actually rely on deep inheritance hierarchies versus favouring simpler, more composed alternatives, since deeply nested inheritance can itself become genuinely hard to follow and modify safely as a codebase grows, and different teams and languages continue to make real, contested choices about how heavily to lean on object-oriented inheritance versus other ways of structuring and reusing code.

This sits inside Object-Oriented Programming Principles, one of eight topics in Programming, one of seven domains in Computer Science, one of seventeen subjects the app can quiz you on.

Draft — not published yet.
Try the pop quiz