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.
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.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.