Microsoft Store
 

Object composition


 

:{{mergefrom|composite type}}

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In computer science, composition is a way and practice to combine simple objects or data types into more complex ones. Compositions are a critical building block of many basic data structures, including the tagged union, the linked list, and the binary tree, as well as the object used in object-oriented programming.

Related Topics:
Computer science - Object - Data type - Tagged union - Linked list - Binary tree

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Composition is contrasted with subtyping, which is the process of adding detail to a general data type to create a more specific data type. In composition, the composite type "has an" object of a simpler type, while in subtyping, the subtype "is an" instance of its parent type. Composition does not form a subtype but a new type.

Related Topics:
Subtyping - Has an - Is an

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Composited objects are called fields, items, members or attributes, and the resulting composition a structure, record, tuple, or composite type. The terms usually vary across languages. Fields are given a unique name so that each one can be distinguished from the others. Sometimes an issue of ownership arises: when a composition is destroyed, should objects belonging to it be destroyed as well? If not, the case is sometimes called aggregation. For more, see the aggregation section below.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In UML, composition is depicted as a filled diamond. It always implies a multiplicity of 1, as only one object at a time can have lifetime responsibility for another object. The more general composition is depicted as an un-filled diamond.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

 

~ Table of Content ~

Introduction
Example
Recursive composition
Composition in various languages
Aggregation
See also

 

 

~ What's Hot ~


~ Community ~

History Forum
Come and discuss about History, Civilizations, Historical Events and Figures
History Web-Ring
A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site.