liveBook · Manning

Abstraction

As explained in Data-Oriented Programming in Java

An abstraction is a simplified representation that hides selected implementation details behind a more general concept or interface.

Abstraction hides selected implementation details behind a general concept. In data-oriented design, resist creating one before the data, ownership, and boundaries are clear. section 10.3.1 section 10.7

When flexibility damages a boundary

A FileRepository with separate loadAccounts, loadInvoices, and loadDisputes methods may look repetitive. Replacing them with a generic load method that accepts a parser appears flexible, but moves file-format knowledge into callers and weakens the repository boundary. The safer abstraction is usually over semantic data, not messy real-world parsing and operational behavior. section 10.4.4

Use abstraction deliberately:

  • Study the data before grouping functionality or choosing reusable concepts. section 10.3.1
  • Prefer abstractions over data, interpreters, and utility functions when they preserve clear architectural boundaries. section 10.4.4
  • Treat extensibility as a cost rather than an automatic improvement; simple operations can remain simple. section 10.7
Listing 10.34 Well typed. Extensible. Flexible. What’s not to love?
void example(Manifest manifest) {
  List<Account> accounts = fileRepo.load(
        manifest.account, AccountParser::parse);
  List<Invoice> invoice = fileRepo.load(
        manifest.invoices, InvoiceParser::parse);
  List<Dispute> dispute = fileRepo.load(
        manifest.disputes, DisputeParser::parse);
}

Compare the apparently flexible generic loader with its callers, which must supply representation-specific parsers and therefore absorb repository knowledge. section 10.4.4

How Data-Oriented Programming in Java covers it

How deep it goes
Contrasts premature and data-oriented abstraction through a repository refactoring, but stops short of formal abstraction theory.
Examples
Uses a FileRepository, typed domain collections, and a generic parser-based loader to expose abstraction trade-offs.
What you can do after
Evaluate abstractions by whether they clarify data boundaries rather than merely increase reuse or extensibility.
How it connects
Connects abstraction with data-oriented architecture, object-oriented programming, interpreters, utility functions, and semantic data types.

Also explained in

Compare how 24 books explain abstraction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.