5

Statefulness

In the end, every program ever written is just a form of y = f(x), where x is all the input you give to the program and y is all the output it delivers in response.

This definition is sufficient for all batch jobs. For example, in a payroll system, the input x is all the employee records and timecards and the output y is all the paychecks and reports.

But perhaps this batch definition is too simplistic. After all, in interactive applications, the input you give to the program is often based on the output it just gave you. So perhaps we should think of interactive software systems as:

void p(Input x) { while (x != DONE) x = (getInput(f(x)) ...

Get Functional Design: Principles, Patterns, and Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.