Aggregate Pattern
   HOME

TheInfoList



OR:

An Aggregate pattern can refer to concepts in either statistics or computer programming. Both uses simplify complexity into smaller, simpler parts.


Statistics

An aggregate pattern is an important statistical concept in many fields that rely on
statistics Statistics (from German language, German: ', "description of a State (polity), state, a country") is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of data. In applying statistics to a s ...
to predict the behavior of large groups, based on the tendencies of subgroups to consistently behave in a certain way. It is particularly useful in
sociology Sociology is the scientific study of human society that focuses on society, human social behavior, patterns of Interpersonal ties, social relationships, social interaction, and aspects of culture associated with everyday life. The term sociol ...
,
economics Economics () is a behavioral science that studies the Production (economics), production, distribution (economics), distribution, and Consumption (economics), consumption of goods and services. Economics focuses on the behaviour and interac ...
,
psychology Psychology is the scientific study of mind and behavior. Its subject matter includes the behavior of humans and nonhumans, both consciousness, conscious and Unconscious mind, unconscious phenomena, and mental processes such as thoughts, feel ...
, and
criminology Criminology (from Latin , 'accusation', and Ancient Greek , ''-logia'', from λόγος ''logos'', 'word, reason') is the interdisciplinary study of crime and deviant behaviour. Criminology is a multidisciplinary field in both the behaviou ...
.


Computer programming

In ''
Design Patterns ''Design Patterns: Elements of Reusable Object-Oriented Software'' (1994) is a software engineering book describing software design patterns. The book was written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, with a fore ...
'', an aggregate is not a
design pattern A design pattern is the re-usable form of a solution to a design problem. The idea was introduced by the architect Christopher Alexander and has been adapted for various other disciplines, particularly software engineering. The " Gang of Four" ...
but rather refers to an object such as a list, vector, or generator which provides an interface for creating
iterator In computer programming, an iterator is an object that progressively provides access to each item of a collection, in order. A collection may provide multiple iterators via its interface that provide items in different orders, such as forwards ...
s. The following example code is in
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
. def fibonacci(n: int): a, b = 0, 1 count = 0 while count < n: count += 1 a, b = b, a + b yield a for x in fibonacci(10): print(x) def fibsum(n: int) -> int: total = 0 for x in fibonacci(n): total += x return total def fibsum_alt(n: int) -> int: """ Alternate implementation. demonstration that Python's built-in function sum() works with arbitrary iterators. """ return sum(fibonacci(n)) myNumbers =
, 7, 4, 3, 22 The comma is a punctuation mark that appears in several variants in different languages. Some typefaces render it as a small line, slightly curved or straight, but inclined from the vertical; others give it the appearance of a miniature fille ...
def average(g) -> float: return float(sum(g)) / len(g) # In Python 3 the cast to float is no longer be necessary
Python hides essentially all of the details using th
iterator protocol
Confusingly, ''
Design Patterns ''Design Patterns: Elements of Reusable Object-Oriented Software'' (1994) is a software engineering book describing software design patterns. The book was written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, with a fore ...
'' uses "aggregate" to refer to the blank in the code for x in ___: which is unrelated to the term "aggregation".
Design Patterns ''Design Patterns: Elements of Reusable Object-Oriented Software'' (1994) is a software engineering book describing software design patterns. The book was written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, with a fore ...
, p. 22: "Aggregation implies that one object owns or is responsible for another object. ... Aggregation implies that an aggregate object and its owner have identical lifetimes."
Neither of these terms refer to the statistical aggregation of data such as the act of adding up the Fibonacci sequence or taking the average of a list of numbers.


See also

*
Visitor pattern A visitor pattern is a software design pattern that separates the algorithm from the object structure. Because of this separation, new operations can be added to existing object structures without modifying the structures. It is one way to follo ...
* Template class *
Facade pattern The facade pattern (also spelled ''façade'') is a software design pattern commonly used in object-oriented programming. Analogous to a façade in architecture, it is an object that serves as a front-facing interface masking more complex underlying ...
*
Type safety In computer science, type safety and type soundness are the extent to which a programming language discourages or prevents type errors. Type safety is sometimes alternatively considered to be a property of facilities of a computer language; that ...
*
Functional programming In computer science, functional programming is a programming paradigm where programs are constructed by Function application, applying and Function composition (computer science), composing Function (computer science), functions. It is a declarat ...


References

Software design patterns Articles with example Python (programming language) code {{compu-prog-stub