Aggregate pattern
Encyclopedia
An Aggregate pattern can refer to concepts in either statistics or computer programming. Both uses deal with considering a large case as composed of smaller, simpler, pieces.

Statistics

An aggregate pattern is an important statistical concept in many fields that rely on statistics
Statistics
Statistics is the study of the collection, organization, analysis, and interpretation of data. It deals with all aspects of this, including the planning of data collection in terms of the design of surveys and experiments....

 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
Sociology is the study of society. It is a social science—a term with which it is sometimes synonymous—which uses various methods of empirical investigation and critical analysis to develop a body of knowledge about human social activity...

, economics
Economics
Economics is the social science that analyzes the production, distribution, and consumption of goods and services. The term economics comes from the Ancient Greek from + , hence "rules of the house"...

, psychology
Psychology
Psychology is the study of the mind and behavior. Its immediate goal is to understand individuals and groups by both establishing general principles and researching specific cases. For many, the ultimate goal of psychology is to benefit society...

, and criminology
Criminology
Criminology is the scientific study of the nature, extent, causes, and control of criminal behavior in both the individual and in society...

.

Computer programming

In Design Patterns
Design Patterns
Design Patterns: Elements of Reusable Object-Oriented Software is a software engineering book describing recurring solutions to common problems in software design. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch. The authors are...

, an aggregate is not a design pattern but rather refers to an object such as a list, vector, or generator which provides an interface for creating iterator
Iterator
In computer programming, an iterator is an object that enables a programmer to traverse a container. Various types of iterators are often provided via a container's interface...

s. The following example code is in Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

.

mylist = ['apples','oranges','milk','eggs','flour']

for item in mylist:
print "Mom, we're out of " + item + "!"

def fibonacci(n):
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):
total = 0
for x in fibonacci(n):
total += x
return total

def fibsum_alt(n):
"""
Alternate implementation. demonstration that Python's built-in function sum
works with arbitrary iterators
"""
return sum(fibonacci(n))

myNumbers = [1,7,4,3,22]

def average(g):
return float(sum(g))/len(g) #in Python 3.0 the cast to float will no longer be necessary

Python hides essentially all of the details using the iterator protocol. Confusingly, Design Patterns
Design Patterns
Design Patterns: Elements of Reusable Object-Oriented Software is a software engineering book describing recurring solutions to common problems in software design. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch. The authors are...

 uses "aggregate" to refer to the blank in the code for x in ___: which is unrelated to the term "aggregation". 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
    Visitor pattern
    In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying those...

  • Template class
  • Facade pattern
    Façade pattern
    The facade pattern is a software engineering design pattern commonly used with Object-oriented programming. The name is by analogy to an architectural facade....

  • Type safety
    Type safety
    In computer science, type safety is the extent to which a programming language discourages or prevents type errors. A type error is erroneous or undesirable program behaviour caused by a discrepancy between differing data types...

  • Functional programming
    Functional programming
    In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK