General information
Category:
Coding, syntax & commands
Environment versions
Network:
Windows 2008 Server
>If it is important that a function returns or changes something different then its value then it's a non good design.
>IOW. If a function just does what is is made for (return a value depending on it's input) no harm can be done by shortcutting.
One example of a common function that has a "side effect" (as part of its implementation) is the pseudo-random number generator function. Each call to the function will modify the seed value. Advantage to this implementation is that you've got repeatability (which of course sounds funny as it seemingly contradicts the usage as (pseudo-)random number generator) for debugging and testing -- you simply start with a specific seed value, then you're guaranteed to have the same sequence of (pseudo-)random numbers being generated. Typical way to "randomize" the values is by using some frequently-changing value as the seed (e.g. the system time).
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only