next up previous index
Next: Documentation and Comments Up: Coding Guidelines Previous: Naming Conventions   Index

Methods and Side-effects

A common type of bug that can be very difficult to find is when a method changes the value of a variable that is defined outside that method. The next two guidelines help prevent these bugs.

Methods that return meaningful values should not have any side effects, except for benign side effects. In programming language jargon, they should act as functions. Benign side effects that don't change the values produced, such as caching a value to speed up processing, are fine though be careful that the lifetime of the values in the cache is what you want.

Methods that have no side effects should return any values. The one exception is some cases where a status code is returned.


next up previous index
Next: Documentation and Comments Up: Coding Guidelines Previous: Naming Conventions   Index
info (at) urbansim.org