Skip to content
public-library›Rules›Code design›Separate pure computation from effects

Separate pure computation from effects

Give each data transformation one responsibility, and make its result depend only on its explicit inputs, without mutating them, reading hidden mutable state, or causing effects. Keep effects, such as network requests, storage, and UI updates, in the code that calls the computation, which may be inside the same module behind a complete operation.

In the full rule