11 IF2250 Desain Dengan UML

70
IF2250 IF2250 IF2250 IF2250 Dasar Dasar Dasar Dasar Rekayasa Rekayasa Rekayasa Rekayasa Perangkat Perangkat Perangkat Perangkat Lunak Lunak Lunak Lunak Desain Desain Desain Desain Desain Desain Desain Desain dengan dengan dengan dengan dengan dengan dengan dengan UML UML UML UML UML UML UML UML (Unified (Unified (Unified (Unified (Unified (Unified (Unified (Unified Modeling Modeling Modeling Modeling Modeling Modeling Modeling Modeling Language) Language) Language) Language) Language) Language) Language) Language) Oleh: Bayu Hendradjaya Pengajar: Bayu Hendradjaya/Christine Suryadi/Yani Widyani Oleh: Bayu Hendradjaya Slide kuliah bisa di download dari kuliah.itb.ac.id /app245(subyek IF2250)

description

UML

Transcript of 11 IF2250 Desain Dengan UML

Page 1: 11 IF2250 Desain Dengan UML

IF2250IF2250IF2250IF2250 DasarDasarDasarDasar RekayasaRekayasaRekayasaRekayasa PerangkatPerangkatPerangkatPerangkat LunakLunakLunakLunak

DesainDesainDesainDesainDesainDesainDesainDesain dengandengandengandengandengandengandengandengan UMLUMLUMLUMLUMLUMLUMLUML(Unified (Unified (Unified (Unified (Unified (Unified (Unified (Unified ModelingModelingModelingModelingModelingModelingModelingModeling Language)Language)Language)Language)Language)Language)Language)Language)

Oleh: Bayu Hendradjaya

Pengajar:

Bayu Hendradjaya/Christine Suryadi/Yani Widyani

Oleh: Bayu Hendradjaya

Slide kuliah bisa di download darikuliah.itb.ac.id /app245(subyek IF2250)

Page 2: 11 IF2250 Desain Dengan UML

UML: UML: UML: UML: Unified Unified Unified Unified Modeling LanguageModeling LanguageModeling LanguageModeling Language

“The Unified Modeling Language (UML) is a

family of graphical notations … that help in

describing and designing software systems, describing and designing software systems,

particularly those built using object-oriented

(OO) style” [Martin Fowler in UML Distilled]

IF2250- Desain dengan UML/Bayu Hendradjaya 2

Page 3: 11 IF2250 Desain Dengan UML

Introduction to UMLIntroduction to UMLIntroduction to UMLIntroduction to UML

• UML: pictures of an OO system

– programming languages are not abstract enough for OO design

– UML is an open standard; lots of companies use it

• What is legal UML?• What is legal UML?

– a descriptive language: rigid formal syntax (like programming)

– a prescriptive language: shaped by usage and convention

• it's okay to omit things from UML diagrams if they aren't needed by team/supervisor/instructor

IF2250- Desain dengan UML/Bayu Hendradjaya 3

Page 4: 11 IF2250 Desain Dengan UML

HistoryHistoryHistoryHistory• Design notation of various kinds used since

programming began:

– Flow charts, Pseudo code, Structure Diagrams …

• With advent of OO, many conflicting notations (1980s , 1990s)

• These notations were combined and unified (late • These notations were combined and unified (late 1990’s)

• UML extensively taught in universities

• (2000 - now).

IF2250- Desain dengan UML/Bayu Hendradjaya 4

Page 5: 11 IF2250 Desain Dengan UML

Uses for Uses for Uses for Uses for UMLUMLUMLUML(Both forward & reverse engineering)(Both forward & reverse engineering)(Both forward & reverse engineering)(Both forward & reverse engineering)

• as a sketch: to communicate aspects of system– forward design: doing UML before coding

– backward design: doing UML after coding as documentation

– often done on whiteboard or paper

– used to get rough selective ideas

as a blueprint: a complete design to be implemented• as a blueprint: a complete design to be implemented– sometimes done with CASE (Computer-Aided Software

Engineering) tools

• as a programming language: with the right tools, code can be auto-generated and executed from UML– only good if this is faster than coding in a "real" language

IF2250- Desain dengan UML/Bayu Hendradjaya 5

Page 6: 11 IF2250 Desain Dengan UML

Diagram

UML

Structured

Diagram

Behavior

Diagram

Class Diagram

Component Diagram

Use Case Diagram

Activity DiagramComponent Diagram

Composite Structure Diagram

Deployment Diagram

Object Diagram

Package Diagram

Activity Diagram

State Machine Diagram

Sequence Diagram

Communication Diagram

Interaction Overview Diagram

Timing Diagram

Interaction Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 6

Page 7: 11 IF2250 Desain Dengan UML

Class Diagrams

Page 8: 11 IF2250 Desain Dengan UML

UML class diagramsUML class diagramsUML class diagramsUML class diagrams• What is a UML class diagram?

– UML class diagram: a picture of the classes in an OO system, their fields and methods, and connections between the classes that interact or inherit from each other

• What are some things that are not represented in a UML

class diagram?

� details of how the classes interact with each other

� algorithmic details; how a particular behavior is implemented

IF2250- Desain dengan UML/Bayu Hendradjaya 8

Page 9: 11 IF2250 Desain Dengan UML

Example UML Class Diagram

http://www.agiledata.org/images/oo101ClassDiagram.gifIF2250- Desain dengan UML/Bayu Hendradjaya 9

Page 10: 11 IF2250 Desain Dengan UML

Diagram of one class

• class name in top of box

– write <<interface>> on top of interfaces' names

– use italics for an abstract class name

• attributes (optional)

– should include all fields of the object– should include all fields of the object

• operations / methods (optional)

– may omit trivial (get/set) methods

• but don't omit any methods from an interface!

– should not include inherited methods

IF2250- Desain dengan UML/Bayu Hendradjaya 10

Page 11: 11 IF2250 Desain Dengan UML

Class attributes

• attributes (fields, instance variables)

– visibility name : type [count] = default_value

– visibility: + public

# protected

- private

~ package (default)

11

~ package (default)

/ derived

– underline static attributes

– derived attribute: not stored, but can

be computed from other attribute values

– attribute example:

- balance : double = 0.00

IF2250- Desain dengan UML/Bayu Hendradjaya 11

Page 12: 11 IF2250 Desain Dengan UML

Class operations / methods

• operations / methods

– visibility name (parameters) : return_type

– visibility: + public

# protected

- private

~ package (default)

12

~ package (default)

– underline static methods

– parameter types listed as (name: type)

– omit return_type on constructors and

when return type is void

– method example:

+ distance(p1: Point, p2: Point): double

IF2250- Desain dengan UML/Bayu Hendradjaya 12

Page 13: 11 IF2250 Desain Dengan UML

Instance Specification(Object)

ObjectName: Class Name

Attribute : type

Operation (arg list) : return type

Abstract operation

Various parts are optional

IF2250- Desain dengan UML/Bayu Hendradjaya 13

Page 14: 11 IF2250 Desain Dengan UML

Comments

• represented as a folded note, attached to the

appropriate class/method/etc by a dashed line

IF2250- Desain dengan UML/Bayu Hendradjaya 14

Page 15: 11 IF2250 Desain Dengan UML

Associational relationshipsAssociational relationshipsAssociational relationshipsAssociational relationships

• associational (usage) relationships1. multiplicity (how many are used)

• * ⇒ 0, 1, or more

• 1 ⇒ 1 exactly

• 2..4 ⇒ between 2 and 4, inclusive

• 3..* ⇒ 3 or more

2. name (what relationship the objects have)

3. navigability (direction)

IF2250- Desain dengan UML/Bayu Hendradjaya 15

Page 16: 11 IF2250 Desain Dengan UML

� one-to-one� each student must carry exactly one ID card

� one-to-manyone rectangle list can contain many rectangles

Multiplicity of associationsMultiplicity of associationsMultiplicity of associationsMultiplicity of associations

� one rectangle list can contain many rectangles

IF2250- Desain dengan UML/Bayu Hendradjaya 16

Page 17: 11 IF2250 Desain Dengan UML

Association typesAssociation typesAssociation typesAssociation types

• aggregation: "is part of" – symbolized by a clear white diamond

• composition: "is entirely made of"– stronger version of aggregation– the parts live and die with the whole

1

1

Car

aggregation

Engine

Book

composition

1– the parts live and die with the whole– symbolized by a black diamond

• dependency: "uses temporarily"– symbolized by dotted line– often is an implementation

detail, not an intrinsic part ofthat object's state

LotteryTicket

Random

dependency

Page

*

1

IF2250- Desain dengan UML/Bayu Hendradjaya 17

Page 18: 11 IF2250 Desain Dengan UML

Generalization (Inheritance)

Supertype

Subtype 1 Subtype 2

• Generalization: an inheritance relationship

– inheritance between classes

– interface implementation

IF2250- Desain dengan UML/Bayu Hendradjaya 18

Page 19: 11 IF2250 Desain Dengan UML

Generalization Relationships• Generalization (inheritance) relationships

– hierarchies drawn top-down with arrows

pointing upward to parent

– line/arrow styles differ, based on whether parent

is a(n):

• class:

solid line, black arrowsolid line, black arrow

• abstract class:

solid line, white arrow

• interface:

dashed line, white arrow

– we often don't draw trivial / obvious

generalization relationships, such as drawing the

Object class as a parent

IF2250- Desain dengan UML/Bayu Hendradjaya 19

Page 20: 11 IF2250 Desain Dengan UML

Class diagram example 1

IF2250- Desain dengan UML/Bayu Hendradjaya 20

Page 21: 11 IF2250 Desain Dengan UML

Class diagram example 2

Rental Invoice

Customer1

Class

Abstract

Class

Simple

Aggregation

Multiplicity

DVD Movie VHS Movie Video Game

Rental Item 1..*1

Checkout Screen

0..1

Simple

Association

Class

Generalization

Composition

IF2250- Desain dengan UML/Bayu Hendradjaya 21

Page 22: 11 IF2250 Desain Dengan UML

Class diagram example 3

StudentBodyStudentBodyStudentBodyStudentBody

+ main (args : String[])+ main (args : String[])+ main (args : String[])+ main (args : String[])

1 100StudentStudentStudentStudent

---- firstName : StringfirstName : StringfirstName : StringfirstName : String---- lastName : StringlastName : StringlastName : StringlastName : String---- homeAddress : AddresshomeAddress : AddresshomeAddress : AddresshomeAddress : Address

+ toString() : String+ toString() : String+ toString() : String+ toString() : String

---- homeAddress : AddresshomeAddress : AddresshomeAddress : AddresshomeAddress : Address---- schoolAddress : AddressschoolAddress : AddressschoolAddress : AddressschoolAddress : Address

+ toString() : String+ toString() : String+ toString() : String+ toString() : String

---- streetAddress : StringstreetAddress : StringstreetAddress : StringstreetAddress : String---- city : Stringcity : Stringcity : Stringcity : String---- state : Stringstate : Stringstate : Stringstate : String---- zipCode : longzipCode : longzipCode : longzipCode : long

AddressAddressAddressAddress

IF2250- Desain dengan UML/Bayu Hendradjaya 22

Page 23: 11 IF2250 Desain Dengan UML

Sequence Diagrams

Page 24: 11 IF2250 Desain Dengan UML

UML sequence diagramsUML sequence diagramsUML sequence diagramsUML sequence diagrams• Sequence diagram: an "interaction diagram"

that models a single scenario executing in the

system

– perhaps 2nd most used UML diagram (behind

class diagram)class diagram)

• relation of UML diagrams to other exercises:

– CRC cards -> class diagram

– use cases -> sequence diagrams

IF2250- Desain dengan UML/Bayu Hendradjaya 24

Page 25: 11 IF2250 Desain Dengan UML

Key parts of a sequence diag.Key parts of a sequence diag.Key parts of a sequence diag.Key parts of a sequence diag.• Participant: an object or entity that acts in the

sequence diagram

– sequence diagram starts with an unattached "found message" arrow

• Message: communication between participant • Message: communication between participant objects

• The axes in a sequence diagram:

– horizontal: which object/participant is acting

– vertical: time (down -> forward in time)

IF2250- Desain dengan UML/Bayu Hendradjaya 25

Page 26: 11 IF2250 Desain Dengan UML

Elements of Sequence Diagrams

Name: Class

New object

Create

There is also notation for loops, conditions, etc.

Message

Return

Delete

Self-call

IF2250- Desain dengan UML/Bayu Hendradjaya 26

Page 27: 11 IF2250 Desain Dengan UML

Sequence Diagram Sequence Diagram Sequence Diagram Sequence Diagram from use casefrom use casefrom use casefrom use case

IF2250- Desain dengan UML/Bayu Hendradjaya 27

Page 28: 11 IF2250 Desain Dengan UML

Representing objectsRepresenting objectsRepresenting objectsRepresenting objects• Squares with object type, optionally preceded by

object name and colon

– write object's name if it clarifies the diagram

– object's "life line" represented by dashed vert. line

IF2250- Desain dengan UML/Bayu Hendradjaya 28

Page 29: 11 IF2250 Desain Dengan UML

• Message (method call) indicated by horizontal arrow to other object

– write message name and arguments above arrow

Messages between objectsMessages between objectsMessages between objectsMessages between objects

IF2250- Desain dengan UML/Bayu Hendradjaya 29

Page 30: 11 IF2250 Desain Dengan UML

Messages, continuedMessages, continuedMessages, continuedMessages, continued• message (method call) indicated by horizontal arrow

to other object– dashed arrow back indicates return

– different arrowheads for normal / concurrent (asynchronous) methods

IF2250- Desain dengan UML/Bayu Hendradjaya 30

Page 31: 11 IF2250 Desain Dengan UML

Lifetime of objectsLifetime of objectsLifetime of objectsLifetime of objects

• creation: arrow with 'new'

written above it

– notice that an object created

after the start of the scenario

appears lower than the others

• deletion: an X at bottom of

object's lifeline

– Java doesn't explicitly delete

objects; they fall out of scope and

are garbage-collected

IF2250- Desain dengan UML/Bayu Hendradjaya 31

Page 32: 11 IF2250 Desain Dengan UML

Indicating method calls

• activation: thick box over object's life line; drawn when

object's method is on the stack

– either that object is running its code, or it is on the stack

waiting for another object's method to finish

– nest to indicate recursion

Activation

Nesting

IF2250- Desain dengan UML/Bayu Hendradjaya 32

Page 33: 11 IF2250 Desain Dengan UML

Indicating selection and loops

• frame: box around part of a sequence diagram to indicate selection or loop– if -> (opt) [condition]

– if/else -> (alt) [condition], separated by horizontal dashed line

– loop -> (loop) [condition or items to loop over]

33

Page 34: 11 IF2250 Desain Dengan UML

Linking sequence diagrams• if one sequence diagram is too large or refers to another diagram, indicate

it with either:

– an unfinished arrow and comment

– a "ref" frame that names the other diagram

– when would this occur in our system?

IF2250- Desain dengan UML/Bayu Hendradjaya 34

Page 35: 11 IF2250 Desain Dengan UML

Example sequence diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 35

Page 36: 11 IF2250 Desain Dengan UML

Forms of system control• What can you say about the control flow of each of the

following systems?

– Is it centralized?

– Is it distributed?

36

Page 37: 11 IF2250 Desain Dengan UML

Flawed sequence diagram 1• What's wrong with this sequence diagram? (Look at the UML syntax and

the viability of the scenario.)

IF2250- Desain dengan UML/Bayu Hendradjaya 37

Page 38: 11 IF2250 Desain Dengan UML

Flawed sequence diagram 2What's wrong with this sequence diagram?

IF2250- Desain dengan UML/Bayu Hendradjaya 38

Page 39: 11 IF2250 Desain Dengan UML

Why not just code it?

• Sequence diagrams can be somewhat close to the

code level. So why not just code up that algorithm

rather than drawing it as a sequence diagram?

� a good sequence diagram is still a bit above the level of the real code (not all code is drawn on diagram)on diagram)

� sequence diagrams are language-agnostic (can be implemented in many different languages

� non-coders can do sequence diagrams

� easier to do sequence diagrams as a team

� can see many objects/classes at a time on same page (visual bandwidth)

IF2250- Desain dengan UML/Bayu Hendradjaya 39

Page 40: 11 IF2250 Desain Dengan UML

Example for Sequence Diagram[Fowler]

• We have an order and are going to invoke a command on it to calculate its price. To do that, the order needs to look at all the line items on the order and determine their prices, items on the order and determine their prices, which are based on the pricing rules of the order line’s products. Having done that for all the line items, the order then needs to compute an overall discount, which is based on rules tied to the customer.

IF2250- Desain dengan UML/Bayu Hendradjaya 40

Page 41: 11 IF2250 Desain Dengan UML

Example for Sequence Diagram[Fowler]

• We have an order and are going to invoke a command on it to calculate its price. To do that, the order needs to look at all the line

items on the order and determine their prices, which are based on the pricing rules of the which are based on the pricing rules of the order line’s products. Having done that for all the line items, the order then needs to compute an overall discount, which is based on rules tied to the customer.

IF2250- Desain dengan UML/Bayu Hendradjaya 41

Page 42: 11 IF2250 Desain Dengan UML

Example Sequence Diagram

anOrder anOrderLine aProduct aCustomer

calculatePricegetQuantity

getProduct

getPricingDetails

aProductFound

message

Participant Lifeline

Return

ActivationgetPricingDetails

getBasePrice

calculateDiscounts

getDiscountInfo

Return

Self call

Message

IF2250- Desain dengan UML/Bayu Hendradjaya 42

Page 43: 11 IF2250 Desain Dengan UML

Object DiagramObject Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 43

Page 44: 11 IF2250 Desain Dengan UML

Object Diagram

• An object diagram is a snapshot of the objects in a system at a point in time.

– Because it shows instances rather than classes, an object diagram is often called an instance diagram.

• When to use?• When to use?

– Object diagrams are useful for showing examples of objects connected together.

• In many situations, you can define a structure precisely with a class diagram, but the structure is still difficult to understand.

• In these situations, a couple of object diagram examples can make all the difference

IF2250- Desain dengan UML/Bayu Hendradjaya 44

Page 45: 11 IF2250 Desain Dengan UML

Contoh Objek

Novel ku : Buku

I sbn : st r i ng[ 10] = “ 3432- 353840”

Nama Objek Nama Kelas

45IF2250- Desain dengan UML/Bayu Hendradjaya

I sbn : st r i ng[ 10] = “ 3432- 353840”

Judul : st r i ng[ 30] = “ Kumpul an Pui si ”

Pener bi t : st r i ng[ 20] = “ Pener bi t I TB”

Juml ahHal aman : i nt = 135

Nama atribut T ipe atribut Nilai Atribut

Page 46: 11 IF2250 Desain Dengan UML

Contoh Kelas Account dan Objeknya

Buku

I sbn : st r i ng[ 10] Judul : st r i ng[ 30]Pener bi t : st r i ngJuml ahHal aman: i nt

Updat eJudul ( )Updat ePener bi t ( )Pendaf t ar anBukuBar u( )PenghapusanBuku( )

46IF2250- Desain dengan UML/Bayu Hendradjaya

Novel ku : Buku

I sbn = “ 3432- 353840”Judul = “ Kumpul an Pui si ”Pener bi t = “ Pener bi t I TB”Juml ahHal aman= 135

Komi k : Buku

I sbn = “ 3432- 3840”Judul = “ Bat man”Pener bi t = “ Pener bi t I TB”Juml ahHal aman= 55

<<instant iate>> <<instant iate>>

Page 47: 11 IF2250 Desain Dengan UML

Class Diagram

Object Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 47

Page 48: 11 IF2250 Desain Dengan UML

Package DiagramPackage Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 48

Page 49: 11 IF2250 Desain Dengan UML

Package Diagram

• A package is a grouping construct that allows

you to take any construct in the UML and

group its elements together into higher-level

units.

– Its most common use is to group classes– Its most common use is to group classes

– In programming terms, packages correspond to

such grouping constructs as packages (in Java) and

namespaces (in C++ and .NET).

IF2250- Desain dengan UML/Bayu Hendradjaya 49

Page 50: 11 IF2250 Desain Dengan UML

Ways of Showing Packages

IF2250- Desain dengan UML/Bayu Hendradjaya 50

Page 51: 11 IF2250 Desain Dengan UML

Dependencies in Package

IF2250- Desain dengan UML/Bayu Hendradjaya 51

Page 52: 11 IF2250 Desain Dengan UML

Deployment DiagramDeployment Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 52

Page 53: 11 IF2250 Desain Dengan UML

Deployment Diagram

• Deployment diagrams show a system's

physical layout, revealing which pieces of

software run on what pieces of hardware.

IF2250- Desain dengan UML/Bayu Hendradjaya 53

Page 54: 11 IF2250 Desain Dengan UML

IF2250- Desain dengan UML/Bayu Hendradjaya 54

Page 55: 11 IF2250 Desain Dengan UML

Activity DiagramActivity Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 55

Page 56: 11 IF2250 Desain Dengan UML

Activity Diagram

• Activity diagrams are a technique to

– describe procedural logic, business process, and

work flow.

– In many ways, they play a role similar to

flowcharts, but the principal difference between flowcharts, but the principal difference between

them and flowchart notation is that they support

parallel behavior.

.

IF2250- Desain dengan UML/Bayu Hendradjaya 56

Page 57: 11 IF2250 Desain Dengan UML

Example of Activity Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 57

Page 58: 11 IF2250 Desain Dengan UML

Decomposing An Action

Actions can be decomposed into

subactivities

IF2250- Desain dengan UML/Bayu Hendradjaya 58

Page 59: 11 IF2250 Desain Dengan UML

Subsidiary Activity Subsidiary Activity Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 59

Page 60: 11 IF2250 Desain Dengan UML

Partitions

Activity diagrams tell you

what happens, but they

do not tell you who does

whatwhat

IF2250- Desain dengan UML/Bayu Hendradjaya 60

Page 61: 11 IF2250 Desain Dengan UML

Activity Diagram use

IF2250- Desain dengan UML/Bayu Hendradjaya 61

Page 62: 11 IF2250 Desain Dengan UML

State Machine DiagramState Machine Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 62

Page 63: 11 IF2250 Desain Dengan UML

State Machine Diagram

IF2250- Desain dengan UML/Bayu Hendradjaya 63

Page 64: 11 IF2250 Desain Dengan UML

Software Lifecycle: UML Can Be Used at Various Stages

• Analysis: OOA

– What is system to do? What services is it to

provide? Provide requirements for designer.

• Design: OOD• Design: OOD

– What will be the parts & structure of the system?

How will they interact? Provide blueprint for

programmer.

• Programming: OOP

IF2250- Desain dengan UML/Bayu Hendradjaya 64

Page 65: 11 IF2250 Desain Dengan UML

Putting UML into Processes

• Requirement Analysis– Use cases, which describe how people interact with

the system.

– A class diagram drawn from the conceptual perspective, which can be a good way of building up a rigorous vocabulary of the domain.

– An activity diagram, which can show the work flow of – An activity diagram, which can show the work flow of the organization, showing how software and human activities interact. An activity diagram can show the context for use cases and also the details of how a complicated use case works.

– A state diagram, which can be useful if a concept has an interesting life cycle, with various states and events that change that state.

IF2250- Desain dengan UML/Bayu Hendradjaya 65

Page 66: 11 IF2250 Desain Dengan UML

Putting UML into Processes (2)

• Desain– Class diagrams from a software perspective. These

show the classes in the software and how they interrelate.

– Sequence diagrams for common scenarios. A valuable approach is to pick the most important and interesting scenarios from the use cases and use CRC cards or scenarios from the use cases and use CRC cards or sequence diagrams to figure out what happens in the software.

– Package diagrams to show the large-scale organization of the software.

– State diagrams for classes with complex life histories.

– Deployment diagrams to show the physical layout of the software.

IF2250- Desain dengan UML/Bayu Hendradjaya 66

Page 67: 11 IF2250 Desain Dengan UML

Design phase

• Design: specifying the structure of how a software system will be written and function, without actually writing the complete implementation

• A transition from "what" the system must do, to "how" the system will do itsystem will do it

– What classes will we need to implement a system that meets our requirements?

– What fields and methods will each class have?

– How will the classes interact with each other?

IF2250- Desain dengan UML/Bayu Hendradjaya 67

Page 68: 11 IF2250 Desain Dengan UML

How do we design classes?

• class identification from project spec / requirements– nouns are potential classes, objects, fields

– verbs are potential methods or responsibilities of a class

• CRC card exercises– write down classes' names on index cards

68

– write down classes' names on index cards

– next to each class, list the following:• responsibilities: problems to be solved; short verb phrases

• collaborators: other classes that are sent messages by this class (asymmetric)

• UML diagrams– class diagrams (today)

– sequence diagrams

– ... IF2250- Desain dengan UML/Bayu Hendradjaya 68

Page 69: 11 IF2250 Desain Dengan UML

Tugas

Untuk topik masing-masing:

• Buat SKPL untuk pendekatan berorientasi

objek (template ada di situs) yang mencakup:

– Diagram use case dan skenario-nya

– Untuk setiap use case:– Untuk setiap use case:

• Buat diagram kelas

• Buat diagram activity (menggambarkan seluruh

alternatif skenario)

• Dikumpulkan: 14 April 2015 (jam kuliah)

69IF2250- Desain dengan UML/Bayu Hendradjaya

Page 70: 11 IF2250 Desain Dengan UML

Closing

•• Slide AcknowledgementSlide Acknowledgement

– “Introduction to UML: Unified Modeling Language”, Slide Presentation of Ric Holt, U. Waterloo, March 2009 CS246

– “Design and UML Class Diagrams” Slide presentation of Marty Stepp, U. Washington, 2007.

•• TextBookTextBook: : –– Martin Fowler,Martin Fowler, “UML Distilled: a brief guide to the standard object

modeling language. 3rd edition” Addison-Wesley Professional, 2004.

–– Scott W. Ambler, “Scott W. Ambler, “The Object Primer: Agile Model Driven Development

with UML 2. 3rd edition” Cambridge University Press, 2004.

70IF2250- use-case