liveBook · Manning

Action

As explained in Grokking Simplicity

An action is a computation whose observable result depends on when or how it is performed and may involve effects beyond producing a value.

An action is code whose meaning depends on when it runs, how many times it runs, or both. It affects the world or is affected by it, so repeated or reordered execution can change the result. Sending email, reading a database, changing state, and handling a UI event are actions. section 1.19 section 3.9

Actions belong beside calculations and data in a basic functional-programming distinction. Calculations derive outputs from inputs without time-dependent effects, while data records facts. Prefer data and calculations where possible, then isolate the actions that must perform work. section 3.1 section 3.11

Recognize actions by their dependence on execution:

  • Treat sending an email as an action because sending it twice differs from sending it once. section 1.17
  • Treat database reads, message receipt, database changes, and UI events as actions because timing or repetition matters. section 1.12 section 1.14 section 1.15
  • Watch for function calls, method calls, constructors, expressions, and statements; JavaScript can implement actions and calculations with the same function construct. section 3.9
  • Remember that actions spread: a function calling an action becomes an action, as do its callers. section 3.8

Planning before sending

A coupon campaign fetches subscribers and coupons, both actions, then calculates an email plan as data. Sending the prepared emails remains an action. Separating decisions from execution makes the calculations easier to test and leaves the time-sensitive work in a smaller boundary. section 3.5 section 3.6

Tracing action spread

In an affiliate payout flow, transferring money is an action. The payout calculator, affiliate loop, and program entry point become actions when they call it, even though some surrounding code only computes amounts or chooses recipients. section 3.7

Image

Use the category diagram to compare actions with calculations and inert data, then locate time-dependent work before refactoring. section 1.10

How Grokking Simplicity covers it

How deep it goes
Defines actions, identifies common forms, traces their spread, and stops short of detailed safety techniques for managing them.
Examples
Uses UI events, database operations, email delivery, coupon campaigns, affiliate payouts, shopping, and JavaScript expressions.
What it assumes
Teaches the action-calculation-data distinction from zero while assuming only familiarity with ordinary software code and basic JavaScript examples.
What you can do after
Diagnose actions in new and existing code, separate calculations from them, and identify where timing and repetition require care.
How it connects
Connects actions with calculations, data, side effects, state, distributed systems, testing, and timeline diagrams.

Also explained in

Compare how 13 books explain action →

Related concepts

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