liveBook · Manning

Expressive code

As explained in Data-Oriented Programming in Java

Code whose structure and data representations communicate its meaning directly and with little implicit behavior.

Expressive code makes meaning visible in its structure and data representations. Instead of hiding behavior behind a void method such as reschedule(), it accepts a domain value and returns a domain result, reducing guesswork and codebase hunting. section 1.4

Making rescheduling explicit

A data-oriented refactoring turns reschedule into a function from FailedTask to RetryDecision. Pattern matching then returns RetryImmediately, ReattemptLater, or Abandoned directly, so the method's inputs, outputs, and alternatives are visible at a glance. section 1.4

Expressive code tends to:

  • Expose domain semantics through meaningful types rather than implicit object state. section 1.4
  • Shape methods as expressions that take data in and return data out. section 1.4
  • Let data representations guide implementation and make valid alternatives visible. section 1.4

How Data-Oriented Programming in Java covers it

How deep it goes
Defines the technique, contrasts ambiguous void methods with typed data flow, and demonstrates a switch-based refactoring.
Examples
Uses scheduler rescheduling, FailedTask, RetryDecision, and TerminalState examples.
What you can do after
Apply it by refactoring implicit behavior into explicit data transformations with visible results and alternatives.
How it connects
Connects expressive code to data-oriented programming, type signatures, pattern matching, and sealed types.

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.