Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Diagram.

Similar presentations


Presentation on theme: "Class Diagram."— Presentation transcript:

1 Class Diagram

2 Class Diagram A class diagram shows the existence of classes and their relationships in the logical view of the system. Graphical presentation of the static view.

3 Classes A class is represented as a three-part box Class Name
Attributes At conceptual level it is a piece of information associated with the class that can be accessed and possibly modified Corresponds to a field at the implementation level

4 Operations The processes the class can carry out (methods at implementation level) - Basic operations (such as getValue) on attributes can be omitted (they can be inferred)

5 Classes Attribute syntax: visibility name: type = defaultValue
Operation syntax: visibility name(parameter-list): return-type Customer Class Name Name address Attributes +creditRating():String Operations

6 Path name (Package-name :: Class-name)
Visibility: - public + - protected # - private – Class Names: Simple Path name (Package-name :: Class-name) Window Banking :: CheckingAccount For abstract classes, class name is written in italic: Customer

7 Abstract Class Abstract Operation

8 Class Diagram - Relationship
Association: bi-directional semantic relationship Aggregate: a whole and part relationship Generalization: inheritance relationship Dependency: single-directional relationship between a client class and a supplier class/interface Realize: single-directional relationship. A class realizes the operations offered by the interface.

9 Structural Modeling: Core Relationships

10 Structural Modeling: Core Relationships (cont’d)

11 Associations Associations are shown as lines between classes
An association shows a relationship between instances of two classes Each association has two roles (one for each direction) A role can be explicitly named with a label Roles have multiplicity showing how many objects participate in the relationship

12

13 Associations can have multiplicities:
A fixed value (such as 1 or 3) Many denoted by * (unlimited number) A range of values 0..1 or 3..* A set of values 2,4,8

14 Adds attributes and operations to an association
Association Class Adds attributes and operations to an association Allows exactly one instance of the association class between any two objects Can use an actual class instead, if you need more 0..4 10..20 Student Course Grade

15 0..* 1..* Company Person employer employee Job description dateHired salary

16 Qualified Association
Association can be keyed by the value of the qualifier. A qualifier is used to reduce the scope of an association. A qualifier in an association solves the lookup problem. qualifier 1 * finds Reservation Clerk Confirmation Number

17 Constraints Represent further restrictions on associations or classes
A constraint is shown as a text string enclosed in braces { }. A constraint is a restriction on one or more values of (part of) an object-oriented model or system. {ordered } Serves Bank Teller Customer Chooses Academic High School Student { or } Chooses Commercial

18 1 1 1 1 * * * 1 Meal - - - - - - - - { or } - - - - - - - - -
{ precedes } 1 1 1 1 Soup Salad Main Course Dessert * Member-of * Committee Person { subset } Chair-of * 1

19 ATM_Withdrawl Account
customer : id amount : Money {amount is multiple of $20} Account balance : Money

20 Aggregation and Composition
Aggregation is a part-of relationship. Composition is also a part-of relationship, but part and whole live and die together In aggregation, parts may be added or removed, they may survive even after the whole is dead while in composition parts are contained in the whole and die with the container. Aggregation is more loosely coupled than composition.

21 1 1 2 1 1 Computer shows aggregation Speaker CPU Keyboard Monitor
Mouse

22 Table shows composition 1 4 Leg Table Top

23 Generalization Sharing mechanism based on
Customer Sharing mechanism based on a hierarchical relationship between classes. Subtype is a specialization of the supertype. Is-kind-of Relationship name address creditRating():String indicates generalization Corporate Customer Personal Customer creditCardNumber contactName creditRating creditLimit remind() billForMonth(Int)

24 Generalization Relationship
vehicle land vehicle water vehicle car amphibian vehicle ship

25 Dependency Relationship

26 Realization Relationship
Realization is the relationship between a class and an interface. The class is said to realize the operations in the interface.

27


Download ppt "Class Diagram."

Similar presentations


Ads by Google