Presentation is loading. Please wait.

Presentation is loading. Please wait.

School of Computer Science and Engineering

Similar presentations


Presentation on theme: "School of Computer Science and Engineering"— Presentation transcript:

1 School of Computer Science and Engineering
Class Diagrams Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University

2 CLASS in UML Class Name Attribute1 Attribute2 … Operation1 Operation2
responsibility

3 CLASS in UML Class name WashingMachine First letter is upper-case
No empty space in a class name. with package name? package_name::class_name Ex) HouseholdAppliances::WashingMashine WashingMachine

4 myWasher:WashingMachine
CLASS in UML Attribute Attribute Names Additional information (attribute vale) can be specified. Ex) capacity:Integer = 8 WashingMachine brandName modeName serialNumber capacity Instance of WashingMachine myWasher:WashingMachine brandName = “TROMM” modeName = “WD-R121XH” serialNumber = “LG57774” capacity = 12

5 CLASS in UML Operation WashingMachine brandName class methods modeName
addClothes() removeClothes() addDetergent() turnOn() brandName modeName serialNumber capacity WashingMachine class methods first letter is lower-case Additional information (e.g. signature) can be specified. Ex) addClothes( C:String )

6 Additional information (signature) in operations
WashingMachine brandName modelName serialNumber capacity addClothes( C:String ) removeClothes( C:String ) addDetergent( D:Integer) turnOn( ):Boolean - Parameter name and type - Return type

7 Stereotype WashingMachine WashingMachine WashingMachine brandName
. . . addClothes() WashingMachine <<id info>> brandName modelName serialNumber <<machine info>> capacity <<clothes-related>> addClothes() removeClothes() addDetergent() <<machine-related>> turnOn() If the lists of class attributes and operations are long, stereotype can be used to separate the list for better understanding. stereotype one or extensibility machanisms in UML allow designers to extend the vocabulary of UML in order to create new model elements Notation :<<stereotype_name>>

8 Responsibility and Constraints
Use when inserting constraints a class has to follow. Notation : text in ‘{ }’ WashingMachine <<id info>> brandName modelName serialNumber <<machine info>> capacity <<clothes-related>> addClothes() removeClothes() addDetergent() <<machine-related>> turnOn() Responsibility : Take dirty clothes as input and produce clean clothes as output {capacity =5 or 8 or 10 Kg} Explain what class has to do

9 Note WashingMachine brandName modelName serialNumber capacity
<<id info>> brandName modelName serialNumber <<machine info>> capacity <<clothes-related>> addClothes() removeClothes() addDetergent() <<machine-related>> turnOn() Responsibility : Take dirty clothes as input and produce clean clothes as output Refer to Government Standard EV on generating serial numbers {capacity =5 or 8 or 10 Kg} Note Use when inserting additional information.

10 Class Modeling Class name attribute1 attribute2 … operation1
Nouns during conversation with clients Class name attribute1 attribute2 operation1 operation2 responsibility Nouns during conversation with clients , which are related to class name. Verbs during conversation with clients의뢰

11 Example : modeling basketball game

12 Example : modeling basketball game

13 Basketball Game Conversation with coach
noun ball, basket, team, players, guards, forwards, cener, shot, shot clock, three-point line, free throw, foul, free-throw line, court, game clock verb Shoot, advance, dribble, pass, foul, rebound Initial Class Diagram

14 Initial class diagram Ball diameter volume dribble() shoot() pass()
advance() Player name height weight dribbleBall() passBall() shootBall() rebound() foulOpponent() Forward does most of the intermediate range shooting and rebounding Guard does most of the dribbling and passing Team Basket ShotClock {pro = 24 sec college = 35sec Int’l = 30 sec} center stays near basket, shoots from close range Foul Shot Court GameClock {pro = 4 12-minute quarters college and Int’l=2 20-minute halves} ThreePointLine FreeThrow Duration {pro = 48minutes college and Int’l = 40 minutes FreeThrowLine

15 Association When classes are connected together conceptually, that connection is called association

16 Association

17 Constraints on Association

18 Association Classes Association can have attributes and operations, just like a class.

19 Link An association may have instances, just as an object is an instance of a class

20 Multiplicity The number of objects from one class that relate with a single object in an associated class. One – to – one One – to – many(*) One – to – one or more(*) 1..* One – to – zero or one One – to – a bounded interval ex. one – to – 5 through(..) 10 One – to exactly n ex. One – to – 10 One – to – a set of choices ex. One – to – 5 or(,) 10

21 Multiplicity Possible multiplicities and how to represent them in UML

22 Reflexive Association
Association with itself

23 Inheritance and Generalization
Is a kind of inheritance, Generalization subclass , superclass root class, leaf class

24 abstract class Class that does not have an instance italic font

25 Dependencies one class may use another.
The most common usage of dependency is to show that the signature of one class’s operation uses another class

26 More about class diagrams
집합연관(Aggregation) 복합연관(Composition) 문맥(Contexts) 인터페이스(Interface) 실체화(Realization) 가시성(Visibility)

27 Aggregations A class consists of a number of component classes

28 Constraints on Aggregations
Constraint to show that one component or another is part of whole

29 Composite A strong type of aggregation
Each component in a composite can belong to just one whole

30 composite structure diagram
Show class’s internal structure Show components of a class

31 Interface and Realization
One entity (interface) defines a set of functionalities as a contract, and the other (class) realizes the contract by implementing the functionality defined in the contract.

32 Visibility + : public # : protected - : private


Download ppt "School of Computer Science and Engineering"

Similar presentations


Ads by Google