Briefle words · Code & architecture
Side effect
Anything a function changes or does beyond returning a value, such as editing its input, writing to a database or sending a request.
Say it to an AI
Python module statements.py for our ledger: build_statement(account_id, month) that uses fetch_transactions for the DB query and calculate_monthly_interest for the math. Use verb-noun naming for every function, nouns only for data, so any side effect like a query is obvious from the name.
How an expert would brief the stronger version of “Monthly statement”.
See it
Try it as a puzzle →Python module in a fintech app that builds a customer's monthly account statement.
Why: A's fetch_ warns you that a database call happens; B's transactions() hides a query behind a name that looks like plain data.
More ways experts use it
Python pure function order_total(items, delivery_fee, promo=None) that returns the total in integer cents with a 5% service fee rounded to a whole cent. No side effects: don't mutate items or the order, no globals; handle the FREEDEL promo inside and keep it deterministic so it's trivially unit-testable.
Order total · Code & architecturePython function book_shipment(order, weight_kg, postcode). Fail fast: guard clauses at the top validate the weight (0–1000 kg) and the UK postcode and raise ValidationError before any side effects, like reserving a truck slot or creating the carrier label.
Shipment booking · Code & architecture
Related words
Room 2 · Naming
Learn “Side effect” in a five-minute lesson