UML Delegation TextBox
A Delegate connector defines the internal assembly of a component's external Ports and Interfaces, on a Component diagram. Using a
Delegate connector wires the
internal workings of the system to the outside world, by a delegation of the connections of external interfaces.
UML Design Foundations
1) Identify the class that needs help. A TextBox needs to be drawn in a variety of shapes. First draw the Textbox class. We could use an attribute to decide how to draw the TextBox, but we want a flexible approach that will not require re-coding for each new shape.
2) Identify the class with the desired behaviors; a Shape superclass with sub-classes like Ellipse and Polygon,
and a predefined shape called Cloud.
3) To use these shapes, tell the TextBox about them using aggregation. Remember to assign the multiplicity at each end.
4) Implement the aggregation association using a new attribute in TextBox called boxshape. The data type of boxshape is Shape, the class that is associated with TextBox.
5) Implement the draw() operation in the TextBox by delegating the operation to the Shape object in the boxshape attribute. Now the TextBox class can use a single draw method, for example, operation implementation, no matter what shape is used. New shapes can be added to the Shape hierarchy without ever changing the TextBox class.