liveBook · Manning

Action

As explained in The Art of Code

An action is a lowest-level narrative-code unit representing a small, individual operation or event.

An action is the smallest narrative-code unit: a low-level method that performs one small operation or event. It handles raw mechanics such as running a query, checking a condition, or sending a queue message, usually in one focused chunk and rarely more than two. section 2.3.4

A focused validation action

A method such as validateMandatoryField(fieldValue, fieldName) checks whether one value is blank and raises an appropriate exception. Email validation can then compose this action with uniqueness checking at the scene level, keeping each method readable at its own narrative level. section 2.3.4

Choose the action boundary for clarity rather than line count alone. Extract code when it performs a narrow responsibility or hides cognitively heavy logic, but avoid methods that merely wrap one simple line. If a method accumulates too many actions, split it into scenes or a higher-level chapter. section 2.3.5

Figure 2.2 Hierarchical structure of a story
figure

Use the hierarchy to see how actions compose into scenes, chapters, and a table of contents. section 2.3.4

How The Art of Code covers it

How deep it goes
Defines action scope and decomposition criteria, stopping short of detailed exception-handling guidance.
Examples
Uses database operations, queue messaging, Boolean conditions, and mandatory-field validation to illustrate action boundaries.
What it assumes
Assumes familiarity with methods and basic object-oriented design while defining narrative levels and responsibility boundaries.
What you can do after
Apply narrative decomposition by extracting narrow, clearly named methods from mechanics or cognitively heavy logic.
How it connects
Connects actions with scenes, chapters, tables of contents, narrative code, and the Single Responsibility Principle.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.