DELAPARRA
Index
Color
NL
Category: Programming paradigms

Side Effects

Explained by Updated

What is Side Effects?

Side Effects: Anything a function does beyond returning a value: writing to a database, logging, modifying a variable. FP minimises side effects — they are isolated and explicit. A side effect is anything a function does besides returning a value: writing to a database, sending an email, logging, changing a global variable or modifying an argument passed to it.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Side Effects

How is Side Effects used in practice?

Side effects are necessary; an application that changes nothing is useless. The problem is unexpected side effects. A function called getTotal() that also saves the order surprises everyone who calls it.

What should you keep in mind with Side Effects?

Functional programming keeps side effects isolated and visible. In practice, that means naming functions so their effects are clear, keeping calculations in pure functions, and doing the database writes, emails and API calls in a clearly separated layer. That structure makes the core logic easy to test, and makes it obvious which parts of the code touch the outside world.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with S

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.