Composite Structure Diagrams
Composite Structure Diagram could be used to show:
- internal structure of a classifier - internal structure diagram,
- classifier interactions with environment through ports,
- a behavior of a collaboration - collaboration use diagram.
The term "structure" for this type of diagrams is defined in UML as a composition of interconnected elements, representing run-time instances collaborating over communications links to achieve some common objectives.
Internal Structure Diagrams
Internal structure diagram shows internal structure of a classifier - a decomposition of that classifier into its properties, parts and relationships.
Composite structure diagram overview shows elements of internal structure of structured classifier - roles, parts, connectors.
You can see some examples of internal structure diagrams here:
- Internal Structure - Bank ATM Composite Structure
- Internal Structure - Tomcat 7 Server Composite Structure
Collaboration Use Diagrams
The behavior of the system is the functionality that the system under design will implement or which is already implemented by some existing system. Objects in a system typically cooperate with each other to produce the behavior of a system.
A behavior of a collaboration will eventually be exhibited by a set of cooperating instances (specified by classifiers) that communicate with each other by sending signals or invoking operations. However, to understand the mechanisms used in a design, it may be important to describe only those aspects of these classifiers and their interactions that are involved in accomplishing a task or a related set of tasks, projected from these classifiers.
Collaborations allow us to describe only the relevant aspects of the cooperation of a set of instances by identifying the specific roles that the instances will play.
Interfaces allow the externally observable properties of an instance to be specified without determining the classifier that will eventually be used to specify this instance. Consequentially, the roles in a collaboration will often be typed by interfaces and will then prescribe properties that the participating instances must exhibit, but will not determine what class will specify the participating instances.
The following nodes and edges are typically drawn in a composite structure diagram which shows behavior of a collaboration: collaboration, property, connector, part, collaboration specialization, dependency.
Collaboration elements - roles, parts, connectors.
Collaboration Visit shows cooperation of doctor and patient roles.
Collaboration use represents one particular use (occurrence) or application of the pattern described by a collaboration to a specific situation involving specific classes or instances playing the roles of the collaboration. A collaboration use shows how the pattern described by a collaboration is applied in a given context, by binding specific entities from that context to the roles of the collaboration.
Collaboration use elements - roles, parts, role binding.
Collaboration use childVisit represents one particular use
of the Visit collaboration.
You can see an example of collaboration diagram here:
- Collaboration Use as Design Pattern - Observer Pattern
Classifier (in internal structures and collaborations) is extended with the capability to own collaboration uses. These collaboration uses link a collaboration with the classifier to give a description of the behavior of the classifier.
One of the collaboration uses owned by the classifier may be selected as representing the behavior of the classifier as a whole. The collaboration related to the classifier by this collaboration use shows how the instances corresponding to the structural features of this classifier (e.g., its attributes and parts) interact to generate the overall behavior of the classifier.
The representing collaboration may be used to provide a description of the behavior of the classifier at a different level of abstraction than is offered by the internal structure of the classifier. The properties of the classifier are mapped to roles in the collaboration by the role bindings of the collaboration use.
UML provides some mechanisms to describe a structure of interconnected elements that is created within an instance of a containing classifier. This structure is referred to as internal structure (of classifier) and is applicable both to structured classes as well as collaboration. Internal structure consists of properties, including parts, playing specific roles, and connectors.
Structured classifier Online Shopping with its internal structure.
The multiplicities on the structural features and connector ends indicate the number of instances (objects and links) that may be created within an instance of the containing classifier, either when the instance of the containing classifier is created, or in the case of links, when an object is added as the value of a role, or at a later time.
The lower bound of the multiplicity range indicates the number of instances that are created (unless indicated differently by an associated instance specification or an invoked constructor function); the upper bound of the multiplicity range indicates the maximum number of instances that may be created. The slots corresponding to the structural features are initialized with these instances.
The manner of creation of the containing classifier may override the default instantiation. When an instance specification is used to specify the initial instance to be created for a classifier, the multiplicities of its parts determine the number of initial instances that will be created within that classifier. Initially, there will be as many instances held in slots as indicated by the corresponding multiplicity. Multiplicity ranges on such instance specifications may not contain upper bounds.
All instances corresponding to parts of a structured classifier are destroyed recursively, when an instance of that structured classifier is deleted. The instance is removed from the extent of its classifier, and is itself destroyed. When an instance is removed from a role of a composite object, links that exist due to connectors between that role and others are destroyed.
UML 2.4 specification provides no definition of encapsulation. It also uses term completely encapsulated without appropriate explanation. It states that classifier could be isolated from its environment (encapsulated ?) by using ports. Each port could specify a distinct interaction point between classifier and its environment.
Library Services is classifier encapsulated through Search Port
Structured class is class which extends both encapsulated classifier and structured classifier. (Note, that encapsulated classifier extends structured classifier as well). Because of this, structured class may have both ports and some internal structure.
Library Services is structured class encapsulated through Search Port
Because encapsulated classifier extends structured classifier, structured class may also have an internal structure. The nesting of classifiers defined within the scope of the structured class limits the visibility of the classifiers to the scope of the namespace of the containing structured class and thus supports encapsulation (information hiding) through ports.
Structured class Online Shopping with Shopping port and internal structure.
Property (of internal structures) is subclass of property from kernel and represents a set of instances that are owned by a containing instance of a classifier. It is also a connectable element (from internal structures).
A property which specifies an instance that is not owned using composition by the instance of the containing classifier is shown by graphical nesting of a box symbol with a dashed outline.
Two Data Sources is sources property - but not part - of Search Controller
Part is a property which is contained by classifier using composition. It means that all parts are destroyed when the containing classifier instance is destroyed.
A part is shown by graphical nesting of a box symbol with a solid outline representing the part in a separate compartment within the symbol representing the containing classifier.
Search Controller has 1 to 3 engines - Search Engine part
The part or property box has only a name compartment, which contains a string according to the syntax defined for property from Kernel. Details may be shown within the box indicating specific values for properties.
The multiplicity for a property or part may be shown as a multiplicity mark in the top right corner of the property box.
Search Controller has 1 to 3 engines - Search Engine part
A property symbol may be shown containing just a single name (without the colon) in its name string. This implies the definition of an anonymously named class nested within the namespace of the containing class.
- between the classifier and its environment (service port), or
- between the classifier and its internal parts (behavior port).
Port by default has public visibility.
Service port is used to denote classifier as provider of services with published functionality. Ports are service ports by default.
Service port specifies the services a classifier provides (offers) to its environment as well as the services that a classifier expects (requires) of its environment.
The required interfaces of a port characterize the requests that may be made from the classifier to its environment through this port. The provided interfaces of a port characterize requests to the classifier that other classifiers may make through this port.
Port is shown as a small square symbol. The name of the port is placed near the square symbol. The port symbol may be placed either overlapping the boundary of the rectangle symbol denoting that classifier or it may be shown inside the rectangle symbol.
Library Services class has Search Port
Multiplicity of the port (if any) is shown after the port name in square brackets. Both name and multiplicity of port are optional.
Library Services class has 1 to 6 Search Ports
A provided interface may be shown using the "lollipop" notation attached to the port. A required interface may be shown using the "socket" notation attached to the port.
Search Port provides Search Books and Search Video interfaces and requires Inventory interface
At Search Port, the Library Services class is completely encapsulated - it can be implemented without any knowledge of the environment the class will be embedded in.
The type of a port (provided interface) may be shown after the port name, separated by colon ":". If there are multiple interfaces associated with a port, these interfaces may be listed separated by comma "," near the single interface icon.
1 to 6 Search Ports provide Search Books and Search Video interfaces and require Inventory interface
Port may also be shown as a small square symbol overlapping the boundary of the rectangle symbol denoting a part typed by that classifier.
Behavior port is a port such that requests arriving at this port are sent to the behavior of the classifier owning the port, rather than being forwarded to some contained instances. If there is no behavior defined for this classifier, any communication arriving at the behavior port is lost. By default, ports are not behavior ports.
A behavior port is rendered as a port connected by a solid line to a small state symbol drawn inside the classifier containing the port. The small state symbol denotes the behavior of the containing classifier.
Search Port is behavior port with Search Books provided interface
Connector is feature which specifies a link that enables communication between two or more instances. This link may be an instance of an association, or it may represent the possibility of the instances being able to communicate because their identities are known by virtue of being passed in as parameters, held in variables or slots, or because the communicating instances are the same instance.
The link may be realized by something as simple as a pointer or by something as complex as a network connection. In contrast to associations, which specify links between any instance of the associated classifiers, connectors specify links between instances playing the connected parts only.
A connector is drawn using the notation for association.
The optional name of the connector follows the following syntax:
connector-name ::= [ name ] ':' classname | name
where name is the name of the connector, and classname is the name of the association that is its type. A stereotype keyword within guillemets may be placed above or in front of the connector name. A property string may be placed after or below the connector name.