What is a Side Effect?

We've all heard the commercials or read the prescription information sheets describing the possible side effects of medications.  The side effects described are typically negative (ex: upset stomach).  There are other side effects of a more positive nature; a medication helping treat an illness that it was not designed for, etc.  In software, side effects are very similar.  Software side effects are any 'unexpected' change in application behavior or data / object state that occur due to execution of some code. 

Side effects in software are quite often encountered when debugging.  Evaluating a function in the Visual Studio immediate window or changing which statement to be executed next (set next statement / set instruction pointer) can (and likely will) create side effects.  A prime example of side effects while debugging is setting the next statement to either skip or re-execute a portion of code.  If any of the code that is skipped or re-executed alters state (global, class or local), the behavior of the application will be altered, often unexpectedly.

Software side effects are not limited to debugging -- they can manifest anywhere application state is referenced.  Debugging is often the easiest way to recognize a side effect (ex: a value unexpectedly changes in the Autos, Locals or Watch window).  Be on the lookout for side effects during your debugging session, they can point the way towards otherwise hard to track down bugs.

Take care,
DK

Disclaimers:
This posting is provided "AS IS" with no warranties, and confers no rights.