Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.
"Accumulate and fire" is a programming style in which
the program sets a number of global variables or object, then invokes subroutines or methods which
operate on the globally set values.
This is considered
problematic because:
it is not evident when reading the program
which globals serve as arguments,
programmers can forget to set
a value before invoking,
the state can change in a moment
between setting and invoking, particularly when programming with
threading,
the global variables
may be corrupted by being unintentionally used to pass values to
more than one subroutine.
Some older programming languages make this style hard
to avoid: this is the only way of passing arguments to a subroutine
in many BASIC dialects
(using GOSUB) or to a paragraph in COBOL.
Accumulate and fire is considered an example
of an anti-pattern.