Download presentation
Presentation is loading. Please wait.
1
Modeling Structure – Class Diagram
2
Class Diagram
3
Operations (behaviors) to fulfill the class’s responsibilities. Object class name Attributes
4
Steps in Developing a Class Diagram Identify object classes Identify associations Identify object attributes Organize object classes using inheritance Describe communication using sequence diagrams Group classes
5
Class attributes subClass operations Class Diagram Object subClass
6
Relationships between classes 1.Associations 2.Composition/Aggregation 3.Generalization/Specialization Associations – relationship between classes – E.g, Employee works in Department – Specifies how many instances of one class may relate to a single instance of another class 1-to-1 association Optional association (0, 1, or many) – Company has President – Customer owns Credit Card 1-to-many association Many-to-Many association – Bank manages Account – Course has Student – Student attends Course
7
Showing Association An Association between two classes is shown by a simple line. It can be given a descriptive name and augmented with the Role played by each class and with the Cardinality of the relationship.
8
Associations Has-capital One-to-one association One-to-many association City name:String Workorder schedule() StickyNote x: Integer y: Integer z: Integer * Country name:String [From Bruegge, 2000]
9
Many-to-Many Associations Work on ** MechanicsPlane [From Bruegge, 2000]
10
Sample UML Cardinality Notations
11
Composition and Aggregation Hierarchies Whole/Part Relationships – Show components of more complex class – Composition is stronger relationship than aggregation Composition Hierarchy – Whole and part objects are created, live, die together – Often also has a physical association – Association between instances Aggregation Hierarchy – Part objects of aggregate object may be created and deleted independently of aggregate object – Often used for more abstract whole/part relationships than composite objects
12
Showing Aggregation If one class is contained within another a solid diamond is placed on the line next to the containing class. This is termed by value, Class2 it essentially a value within Class1. If the relationship is a simple aggregation then an empty diamond is used. This is termed by reference, Class1 refers to Class2.
13
Kereta Roda Enjin TempatDuduk Aggregation Example
14
weight Automobile serial number year manufacturer model color drive purchase Aggregation Example Engine horsepower volume on off 4,6 Wheel diameter number of bolts 2,4 Door open close Battery amps volts charge discharge * Brakelight on off [From Bruegge, 2000]
15
Some classes are similar but not identical – Have some attributes in common, others different Common attributes abstracted into generalized class(superclass) – E.g., Account (Account number, Balance) Different attributes are properties of specialized class(subclass) – E.g., Savings Account (Interest) IS A relationship between subclass and superclass – Savings Account IS A Account Generalization / Specialization Hierarchy
16
‘generalization’ showing inheritance Inheritance is shown by a line from the sub-class to the super- class with an arrow pointing to the super class. Super class Sub class
17
STAF Nama Alamat Gaji No.staf STAFPengeluaran Kiragaji cetakslipgaji STAFPentadbiran Kiragaji cetakslipgaji Pengurus Kiragaji cetakslipgaji Example : Inheritance
18
UML Representation of Generalization/Specialization walk() jump() talk() sleep() eat() etc.() last name first name birthdate gender Person enroll() displayGPA() GPA classification Student lecture() rank Teacher Arrowhead indicates generalization/specialization relationship
19
Inheritance Example Cell MuscleCellBloodCellNerveCell StriateSmoothRedWhitePyramidalCortical [From Bruegge, 2000]
20
* Light off on 1 1 Heater 1 Cooler 1 Environmental Controller Define_climate Terminate_climate * 1 1 1 1 1 SystemLog Display RecordEvent Actuator startUp shutDown Temperature Example : Class Diagram
21
User Address Member# Name Subscribe Unsubscribe External Reader Ext. Library Name Borrower Items Borrowed Maximum Loans Library Item No. Copies ShelfNo Status Title Issue Return Shelve Book Author ISBN Pub. Date Publisher CAL Package Distributor Recorded Media Course Text Borrows Aggregation AssociationGeneralization Object /Class 0..* Example : Class Diagram
22
Summary – Class Relationship PlanAnalystPlanMetricsPlanGrowingPlanGardeningPlanControllerCoolerLightHeater FruitGrowingPlan FoodVitaminCalorie analyzes 1..2 1..* 1..23 11 * *1 ** *1 AGGREGATION ASSOCIATION GENERALIZATION / INHERITANCE COMPOSITION
23
Member Services System Class Diagram
24
Class Diagram for KMT Client
25
prepare() check() [check=“true”] remove() needsToReorder() [needsToReorder=“true”] enter new Reorder Item Delivery Item Order Entry window OrderOrder LineStock Item [check=“true”] enter new Sequence Diagram
26
ReOrderItem itemnumber quantity etc… DeliveryItem deliveryadress quantity etc… Order orderNumber date etc… prepare() OrderLine itemnumber quantity etc… StockItem orderNumber minQuantity date etc… needsToReorder(): boolean check(): boolean remove() is_for prepare() enter new()
27
Computer: Computer PrintServer: PrintServer Printer: Printer print(file) User: User print (filename) Queue: Queue [printer free] print(file) [printer busy] store(file)
28
Computer print(filename) PrintServer status(): integer print(file) Printer print(file) Queue store(file) uses Managed by
29
Recap Af ter studying this chapter we learned to: –Understand how to structure requirements with class diagram. –Explain the element of class diagrams –Construct class diagrams.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.