liveBook · Manning

Object-oriented programming

As explained in Data-Oriented Programming: Reduce software complexity

A programming paradigm in which programs are composed from objects that combine state with methods for accessing and manipulating that state.

Object-oriented programming composes programs from objects that combine state with methods for accessing and manipulating that state. That arrangement can make a design look tidy while quietly making its behavior harder to understand. section 1.0

A library system that keeps growing

A library design begins with classes such as Library, Book, BookItem, BookLending, Member, Librarian, User, Catalog, and Author. The class list is manageable; the difficult part is the web of relationships between them. Adding a REST /search endpoint then introduces SearchController, SearchQuery, and SearchResult, with similar classes needed for each new JSON endpoint. section 1.1.1 section 1.2.3

Traditional OOP tends to increase complexity in several connected ways:

  • Mixes code and data in classes, making classes participate in many relations. section 1.2
  • Keeps data mutable, requiring extra reasoning about behavior and explicit synchronization in multithreaded environments. section 1.2
  • Locks data inside objects, making serialization nontrivial. section 1.2
  • Locks code inside classes, encouraging complex class hierarchies. section 1.2
Table 1.1 Aspects of OOP and their impact on system complexity (view table figure)

Aspect

Impact on complexity

Code and data are mixed.

Classes tend to be involved in many relations.

Objects are mutable.

Extra thinking is needed when reading code.

Objects are mutable.

Explicit synchronization is required on multi-threaded environments.

Data is locked in objects.

Data serialization is not trivial.

Code is locked in classes.

Class hierarchies are complex.

Compare OOP aspects with their effects on system complexity, including mutability, serialization, and class hierarchies. section 1.2

Complexity here means difficulty of understanding, not resource consumption. OOP is not condemned outright: design patterns can mitigate complexity, and systems that separate code from data can be simpler. Data-oriented programming offers a related alternative and remains compatible with OOP. section 1.2 section 1.3

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains object composition, class relationships, mutability, serialization, and hierarchies, but does not develop language-specific internals.
Examples
Uses a library-management class diagram and repeated JSON REST endpoint classes to expose relationship and serialization costs.
What you can do after
Evaluate OOP designs by tracing relationships, mutable state, serialization work, and class-hierarchy complexity.
How it connects
Connects OOP with data-oriented programming, functional programming, design patterns, mutability, serialization, and class inheritance.

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 Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.