A daily dose of software engineering wisdom - inspiring, thought provoking, and sometimes just plain dangerous.

Tags: side effects glossary

*Side Effects*

A side effect is when a function / method changes something whilst it runs, so it's behaviour is no longer simply take input and process output. It does something else as well.
Typical examples of side effects include changing global / class variables and IO (to file, socket, etc).

Side effects are generally to be avoided as they will not be obvious to people reading the code.

Methods that return a value (called accessor or query methods) should be idempotent i.e. you should be able to run them again and again without the system changing state. They should have no side effects.

Last published: Monday 31st May 2010

<<Previous     Next>>

carriagereturn.org home