liveBook · Manning

Class

As explained in Data-Oriented Programming: Reduce software complexity

A class is an object-oriented programming construct that defines the structure and behavior of objects and can serve as a type or inheritance basis.

A class defines the objects in an object-oriented design and organizes their data, behavior, and relationships. That organization can clarify a library system—or multiply its complexity. section 1.1.1

A library system becomes a class diagram

Theo models Library, Book, BookItem, BookLending, Member, Librarian, User, Catalog, and Author as classes. User becomes a base class for Member and Librarian, while relationships between the classes carry much of the design's complexity. section 1.1.1

When every endpoint gets a class

For a JSON /search endpoint, Theo creates SearchController, SearchQuery, and SearchResult. Repeating the same arrangement for every endpoint duplicates serialization and deserialization code, turning a tidy abstraction into a maintenance problem. section 1.2.3

A class can serve several roles:

  • Represent a domain entity such as a book, member, or catalog. section 1.1.1
  • Act as a base class, as User does for Member and Librarian. section 1.1.1
  • Aggregate stateless functions operating on related domain entities, reducing the complexity of classes. section 11.8
Figure 1.1 A class diagram for Klafim’s Global Library Management System

Use the class diagram to inspect the proposed entities and their relationships before implementation. section 1.1.1

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explores class responsibilities and relationships through designs, then stops short of presenting a complete implementation.
Examples
Uses a library management design and JSON search endpoint to expose modeling choices and repeated conversion logic.
What you can do after
Evaluate when class-based decomposition clarifies a system and when generic data manipulation can reduce duplication and coupling.
How it connects
Connects classes with objects, inheritance, UML class diagrams, JSON serialization, REST APIs, and data-oriented programming.

Also explained in

Compare how 21 books explain class →

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.