6 Class Diagram - 1
6 Class Diagram - 1
Class diagram is the basically classical representation of the static view of the
system and represents different aspects of the application.
A collection of class diagrams represent the whole system.
The following point should be remembered while drawing class diagram.
1) The name of the class diagram should be meaningful to describe the aspects of
the system.
2) Each element and their relationship should be identified in advance.
3) Responsibility (attributes and methods) of each class should be clearly
identified.
4) For each class, minimum number of properties should be specified, as
unnecessary properties will make the diagram complicated.
5) Use notes whenever required to describe some aspect of the diagram. At the end
of the drawing it should be understandable to the developer/coder.
6) Finally, before making the final version, the diagram should be reanalyzed and
reworked as many times as possible to make it correct.
Relationships and type of Relationship
1) Generalization / Inheritance
Parent
Child 1 Child 2
Attributes
Operations / Function
Name : String
Address : String
DOB : String or Date Return type
Phone No.: Integer
Register() : void
Login() : void
Fill_details(): void
Association:
1 Exactly one
(0……*) zero or more
(1……*) one or more
(0……1) zero or one
(5……7) 5 to 7 mean 5, 6, 7
(4, 6) 4 or 6
Customer Admin
C.ID : Number Admin_ID : String
C.Name : String Admin.Name : String
C.Psw : String Admin_psw : String
C.address : String Admin_email : String
C.Pho No : Number 1 Add_Product() : void
(0.....*)
View Product() : void Confirm_order() : void
Add_to_cart() : void Change_prod() : void
1 Payment() : void Login() : void
Login() : void
Register() : void
1
(1.....*) (1.....*)
Order
(1.....*) Order_ID : Number
Order_status: boolean
Product
Order_date : String
P_Name : String (1.....*)
P_ID : Number Find_detail() : void
P_price : Number (1.....*)
availablestock() : void
1
get_product() : void
(1.....*) 1
Payment
amount : Number
(1.....*) date : date
Payment_no : Number
Cart
Cart.ID : Number Payment_detail(): void
Date : String Slip_generation():void
1
delete_cart() : void
update_cart() : void
Generalization
Hospital Management
Aggregation example
Hospital
Doctor Patient
1) <<a>> 2) {}
Access Constraint
3) Dependency 4) Generlization
Note Package
Org.hibernate
Org.hibernate
Org.hibernate
Org. hibernate
Nested Packages:
Java
Utilities
Graphics File Handling
Java is a package which contains other packages inside Java like,
Utilities, Graphics and File handling etc. this is above is couple of nested
packages.
➢ Visibility of Owned and import element “+” for public and “-” for private
class all elements of library domain package are public except for
account.
Library Domain
+ Catalog
+ Patron
+ Librarian
- Account
Library domain is package and catalogue, and patron, librarian, account are the
members of the package library domain.
Packageable element
➢ Dependency
➢ Generalization
➢ Refinement
1) Dependency
One package depend on another package
Fish Water
2) Generalization
Animal
Fish
Model
Model is a package which captures view of a system.
View of system defined by its purpose and abstraction level. Model is notated
using the ordinary package symbol (a folder icon) with a small triangle in an upper
right corner of the large rectangle business layer model.
Business Layer
➢ If contents of the model are shown with in the large rectangle, the triangle
may be drawn to the right of the model name in the tab.
➢ Service layer model contains service interfaces and message types.
Service Layer
Service Message
Interfaces Types
Package Relationship:
e.g;
If changing the contents of a package P2, affects the contents of another package
P1, has a package dependency on P2.
Package dependency diagram:-
Client Service
• •
• •
• •
• •
Client Service
• •
• •
• •
• •
Package client Package service:
Import service Public class service {
Public class client { ………...
Private service –s; …………
………… }
}
Two types of relationship: unidirectional and Bi-directional:
Unidirectional Diagram:
A A
B
C
Bidirectional Diagram:
A
A
B
B A,
C
A,
,
Bidirectional means from A, we can move to B and A as well.
Use Case Package Diagram:
Banker
Withdraw cash
Deposit Funds
Transition
Customer
Transfer Funds Withdraw Cash Transfer Funds
Customer
Banker
Check Balance
Deposit Funds Check Balance
Login
Maintenance
Login
Problem
Maintenance
person Maintenance
person Problem