Association (object-oriented programming)
   HOME

TheInfoList



OR:

In
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
, association defines a relationship between classes of objects that allows one object instance to cause another to perform an action on its behalf. This relationship is
structural A structure is an arrangement and organization of interrelated elements in a material object or system, or the object or system so organized. Material structures include man-made objects such as buildings and machines and natural objects such ...
, because it specifies that objects of one kind are connected to objects of another and does not represent
behaviour Behavior (American English) or behaviour (British English) is the range of actions and mannerisms made by individuals, organisms, systems or artificial entities in some environment. These systems can include other systems or organisms as wel ...
. In generic terms, the causation is usually called "sending a message", "invoking a
method Method ( grc, μέθοδος, methodos) literally means a pursuit of knowledge, investigation, mode of prosecuting such inquiry, or system. In recent centuries it more often means a prescribed process for completing a task. It may refer to: *Scien ...
" or "calling a member function" to the controlled object. Concrete implementation usually requires the requesting object to invoke a ''method'' or ''member function'' using a
reference Reference is a relationship between objects in which one object designates, or acts as a means by which to connect to or link to, another object. The first object in this relation is said to ''refer to'' the second object. It is called a '' name'' ...
or pointer to the memory location of the controlled object. The objects that are related via the association are considered to act in a
role A role (also rôle or social role) is a set of connected behaviors, rights, moral obligation, obligations, beliefs, and social norm, norms as conceptualized by people in a social situation. It is an expected or free or continuously changing behavi ...
with respect to the association, if object's current state in the active situation allows the other associated objects to use the object in the manner specified by the role. A role can be used to distinguish two objects of the same class when describing its use in the context of the association. A role describes the ''public'' aspects of an object with respect to an association. The ends of the association can have all the characteristics of a property: * They can have a ''multiplicity'', expressed by a lower and an upper limit in the form of "lowerLimit..upperLimit". * You can have a ''name''. * You can declare a ''visibility''. * You can specify whether the end of the association is ''ordered'' and / or ''unique''.


See also

* Aggregation *
Object composition In computer science, object composition and object aggregation are closely related ways to combine objects or data types into more complex ones. In conversation the distinction between composition and aggregation is often ignored. Common kind ...


References

Object-oriented programming {{compu-prog-stub