Professional Documents
Culture Documents
Huma Sheraz
(Lecturer)
LECTURE CONTENTS
2. Class Diagram
4. Composition Relationship
5. Aggregation Relationship
• A class diagram describes the static view of a system in terms of classes and
relationships among the classes
• The UML includes class diagrams to illustrate classes and their associations.
Name
Account_Name
- Custom_Name
Attributes
- Balance
+AddFunds( ) Operations
+WithDraw( )
+Transfer( )
Regular Loyalty
Customer Customer
Subtype1 Subtype2
or: Customer
Generalization expresses a
relationship among related
classes. It is a class that
includes its subclasses.
Regular Loyalty
Customer Customer
Software Construction & Development 9
NOTATION OF CLASS DIAGRAM :COMPOSITION
COMPOSITION
Whole Class
Composition: Expresses a relationship
Class W
among instances of related classes. It
is a specific kind of Whole-Part
relationship.
Class P1 Class P2
•Composition should be used to
express a relationship where the
Part Classes
behavior of Part instances is undefined
Example
without being related to an instance of
the Whole.
Automobile
Container Class
Class C Aggregation: Expresses a relationship among
AGGREGATION instances of related classes. It is a specific kind
of Container-Containee relationship.
Class E1 Class E2
Aggregation is an appropriate relationship
Containee Classes where the Container and its Containees can be
manipulated independently.
Example
Bag
Apples Milk
Register
«method»
// pseudo-code or a specific language is OK ...
public void enterItem( id, qty )
{ endSale()
ProductDescription desc = catalog.getProductDescription(id); enterItem(id, qty)
sale.makeLineItem(desc, qty); makeNewSale()
} makePayment(cashTendered)
•The UML includes a general dependency relationship that indicates that a client
element (classes) has knowledge of another supplier element (other class) and that
a change in the supplier could affect the client.
•Dependency is illustrated with a dashed arrow line from the client to supplier.
•There are many kinds of dependency; here are some common types:
• Having an attribute of the supplier type
•Sending a message to a supplier
•Receiving a parameter of the supplier type
Stack
{
post condition: new size = old size – 1
}
1 1
Product Contains Product
(b) itemID
Catalog Description