UML1

39
1 27/09/2011 1 / 160 / 160 / 160 / 160 / 160 / 160 / 160 / 160 Dr. Farhana Jabeen Software Engineering-1 Lecture 10-14 Dr. Farhana Jabeen 27/09/2011 2 / 160 / 160 / 160 / 160 / 160 / 160 / 160 / 160 Dr. Farhana Jabeen UML The UML is a graphical language for visualizing specifying constructing documenting artifacts of a software-intensive system. Artifacts include: deliverables, such as requirements documents, functional specifications, and test plans materials that are critical in controlling, measuring, and communicating about a system during development and after deployment

Transcript of UML1

Page 1: UML1

1

27/09/2011 11111111 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Software Engineering-1

Lecture 10-14

Dr. Farhana Jabeen

27/09/2011 22222222 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML

The UML is a graphical language for

• visualizing

• specifying

• constructing

• documenting

artifacts of a software-intensive system.Artifacts include:

• deliverables, such as requirements documents, functional specifications, and test plans

• materials that are critical in controlling, measuring, and communicating about a system during development and after deployment

Page 2: UML1

2

27/09/2011 33333333 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

� It is a industry-standard graphical language for specifying, visualizing, constructing, and documenting the artifacts of software systems

� The UML uses mostly graphical notations to express the OO analysis and design of software projects.

� Simplifies the complex process of software design

� Use graphical notation: more clearly than natural language (imprecise) and code (too detailed).

UML

27/09/2011 44444444 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• UML can be used in all phases of software development

– specification of requirements, architectural design, detailed design and implementation

• There are different types of UML diagrams for specifying different aspects of software:

• Functionality, requirements• Use-case diagrams

– Architecture, modularization, decomposition• Class diagrams (class structure)

• Component diagrams, Package diagrams, Deployment diagrams (architecture)

– Behavior• State diagrams, Activity diagrams

– Communication, interaction• Sequence diagrams, Collaboration diagrams

UML

Page 3: UML1

3

27/09/2011 55555555 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• There are tools which support UML– Can be used for developing UML models and analyzing them

• IBM’s Rational Rose is a software development tool based on UML.It has code generation capability, configuration management etc.

– http://www.rational.com/

• Microsoft Visio has support for UML shapes and can be used for basic UML diagram drawing.

– http://www.visual-paradigm.com/

• ArgoUML (http://argouml.tigris.org/), open source tool for developing UML models

• USE (http://www.db.informatik.uni-bremen.de/projects/USE/) an open source tool which supports UML class diagrams and Object Constraint Language

UML

27/09/2011 66666666 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Modelling

Use CaseDiagramsUse Case

DiagramsUse CaseDiagrams

ScenarioDiagramsScenario

DiagramsCommunication(Collaboration)

Diagrams

StateDiagramsState

DiagramsComponentDiagrams

ComponentDiagramsComponent

DiagramsDeploymentDiagrams

StateDiagramsState

DiagramsObjectDiagrams

ScenarioDiagramsScenario

DiagramsState MachineDiagrams

Use CaseDiagramsUse Case

DiagramsSequenceDiagrams

ActivityDiagrams

A model is a complete

description of a system

from a particular

perspective

Models

StateDiagramsState

DiagramsClassDiagrams

Page 4: UML1

4

27/09/2011 77777777 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• Modeling consists of building an abstraction of reality.

• Abstractions are simplifications because:

– They ignore irrelevant details and

– They only represent the relevant details.

• What is relevant or irrelevant depends on the purpose of the model.

Modelling

27/09/2011 88888888 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Structural Diagrams

• Used to visualize, specify, construct, document static aspects of system

– class diagram

– package diagram [not standard UML]

– object diagram

– component diagram

– deployment diagram

Page 5: UML1

5

27/09/2011 99999999 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Behavioral Diagrams

• Used to visualize, specify, construct, document dynamic aspects of system

– use case diagram (usually)

– sequence diagram

– communication (collaboration) diagram

– state machine diagram

– activity diagram

27/09/2011 1010101010101010 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• A full set of use case diagrams shows all the procedures available for interaction with the system. It is a summary of system functionality.

• Use Cases specify the behavior of the system

• Helps visualize the system

Page 6: UML1

6

27/09/2011 1111111111111111 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• The two main components of a use case diagram are use cases and actors.

• An actor represent roles that humans, hardware devices, or external systems play while interacting with a given system

– They are not part of the system and are situated outside of the system boundary

– Actors may be both at input and output ends of a use case

• A use case is an external view of the system that represents some action the user might perform in order to complete a task.

27/09/2011 1212121212121212 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• The use case model is the set of all use cases. It is a complete description of the functionality of the system

and its environment

• Use Case

– A set of scenarios related by a common actor and a goal

– A description of sequences of actions performed by a given

system to produce a result for an actor

– Use cases specify the expected behavior [what], and not the

exact method of making it happen [how]

– To name the use cases, give it a verb name to show the action

that must be performed

– Describe a transaction completely

Page 7: UML1

7

27/09/2011 1313131313131313 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• For example a user placing an order

with a sales company might follow

these steps.

– Browse catalog and select items.

– Call sales representative.

– Supply shipping information.

– Supply payment information.

– Receive conformation number from

salesperson.

27/09/2011 1414141414141414 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• It is important to define the basic flow of a use case

before building the structure of the several flows that are part of it.

• If the speed with which the use case is completed by the

actor is important, then it must be optimized to be as

efficient as possible for the user.

Page 8: UML1

8

27/09/2011 1515151515151515 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• A good use case is also:

– Easy to understand

– Unambiguous

– Complete including all alternate flows

– Specified in a document separate from the use case

diagram

– Agreed with the users of the system

– Mapped to a prototype screen or system interface

prototype

27/09/2011 1616161616161616 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• "X uses Y" indicates

that the task "X" has a

subtask "Y"; that is, in the

process of completing task

"X", task "Y" will be

completed at least once.

• The included use case is a

mandatory part of the

including one

Page 9: UML1

9

27/09/2011 1717171717171717 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML (USE CASE Diagram)

• "X extends Y" indicates that "X" is a task for the same type as "Y", but "X" is a special, more specific case of doing "Y". That is, doing X is a lot like doing Y, but X has a few extra processes to it that go above and beyond the things that must be done in order to complete Y.

• extend relationship where you have one Use Case which adds functionality to another Use Case

– any Use Case can have more than one extend

– use when describing a variation on or in addition to normal behavior

– OPTIONAL BEHAVIOUR

27/09/2011 1818181818181818 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML: USE CASE - CD Player

Page 10: UML1

10

27/09/2011 1919191919191919 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML USE CASE Diagram - Courseware System Description

• For this case study, the task is of constructing the design elements for a system that can be used to manage courses and classes for an organization that specializes in providing training.

• The name of the system is Courseware System.

27/09/2011 2020202020202020 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

UML USE CASE Diagram - Courseware System Description

• The organization offers courses in a variety of areas such as learning management techniques and understanding different software languages and technologies.

• Each course is made up of a set of topics.

• Tutors in the organization are assigned courses to teach according to the area that they specialize in and their availability.

• The organization publishes and maintains a calendar of the different courses and the assigns tutors every year.

• There is a group of course administrators in the organization who manage the courses including course content, assigning courses to tutors, and defining the course schedule.

• The training organization aims to use the Courseware System to get a better control and visibility to the course management and to also streamline the process of generating and managing schedulesfor different courses.

Page 11: UML1

11

27/09/2011 2121212121212121 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram

• The following terms and entities are specific to the system:– Courses and Topics that make up courses

– Tutors that teach courses

– Course Administrators who manage the assignment of courses to tutors

– Calendars and Course Schedules that are generated as a result of the work performed by the course administrators

– Students who refer to Calendars and Course Schedules to decide which courses they wish to take up for study

27/09/2011 2222222222222222 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram

Courseware Actors and Use Cases

• � Actors:

– Tutor, Student, Course Administrator (main actor)

• � Use Cases

– Manage courses: View courses, Manage topics for a

course, and Manage course information

– Manage tutors: View course calendar, View tutors,

Manage tutor information, and Assign courses to tutors

Page 12: UML1

12

27/09/2011 2323232323232323 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram

27/09/2011 2424242424242424 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram

Page 13: UML1

13

27/09/2011 2525252525252525 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram : ATM requirements Capture

• A simplified Automatic Teller Machine

• Which requirements are to be captured?

• The activities in Requirement capture– Identification of system boundaries: actors and use cases

– Diagramming use cases

– Elaborating scenarios

– Diagramming scenarios

27/09/2011 2626262626262626 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram :A Simplified Automatic Teller

Machine

• The ATM is associated with only one bank

– It gives access to all the accounts the customer owns in

the bank

• Several types of transactions can be chained in a

single session

– Withdrawal, deposit, transfer between the customer’s

own accounts, consulting an account

– The customer may obtain a printed receipt for each

transaction

Page 14: UML1

14

27/09/2011 2727272727272727 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• The card contains– an ID number

– an expiration date

– a secret code

• The card must be verified by the ATM– The customer cannot make more than 3 attempts to enter the

correct code, otherwise the card is swallowed

• Interface– Keyboard and screen, with menus

– The customer may cancel the current transaction at meaningful points

USE CASE Diagram :A Simplified Automatic Teller

Machine

27/09/2011 2828282828282828 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• The connections with the bank are kept to a minimum– When a session is opened, a connection makes it possible to

known all the accounts the customer owns

– Every night, the information about the current day transactions are transferred to the bank

• From time to time an employee manually – empties the machine and/or fills it with bank notes

– supplies consumables and does any maintenance that may be needed

USE CASE Diagram :A Simplified Automatic Teller

Machine

Page 15: UML1

15

27/09/2011 2929292929292929 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

USE CASE Diagram :A Simplified Automatic Teller

Machine

• ATM example– Customer using the

teller machine

– Bank

– Maintenance technician

– What about the card itself?

Customer

Bank

Technician

27/09/2011 3030303030303030 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Use Cases

Handle Session

Transfer Daily

Maintain

Bank

Technician

Customer

associationsystem boundary

Page 16: UML1

16

27/09/2011 3131313131313131 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Use Cases

Handle

Session

« include »

Verify

Card

« include »

Authentify

Customer

« include »

Get Customer

Information

Handle

Transaction

« include »

Deliver

Receipt

« extend »

27/09/2011 3232323232323232 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Diagramming Use CasesGeneralization

Handle

Transaction

Handle

Deposit

Handle

Withdrawal

Handle

Consult

Handle

Transfer

Page 17: UML1

17

27/09/2011 3333333333333333 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Diagramming Use Cases

Generalization

• The specialized and generalized use

cases are in a “sort of” relationship

Generalized

Specialized

27/09/2011 3434343434343434 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Diagramming Use CasesGeneralization

Page 18: UML1

18

27/09/2011 3535353535353535 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Use Case and Scenarios

• Use cases classify the ways of using the system

• To each use case correspond many possible usage scenarios

• Thus scenarios– are instances of use cases

– specify use cases

• Each use case has generally– a primary scenario, possibly several (a few)

– several secondary (more exceptional) scenarios

27/09/2011 3636363636363636 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

A use case consists of:– Unique name

– Participating actors

– Entry conditions

– Flow of events

– Exit conditions

– Special requirements

Use Case and Scenarios

Page 19: UML1

19

27/09/2011 3737373737373737 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• Name: Purchase ticket

• Participating actor: Passenger

• Entry condition:

• Passenger standing in front of

ticket distributor.

• Passenger has sufficient

money to purchase ticket.

• Exit condition:

• Passenger has ticket.

Event flow:

1. Passenger selects the

number of zones to be

traveled.

2. Distributor displays the

amount due.

3. Passenger inserts

money, of at least the

amount due.

4. Distributor returns

change.

5. Distributor issues ticket.

Scenarios for Use Cases

27/09/2011 3838383838383838 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Scenarios for Use Cases

Page 20: UML1

20

27/09/2011 3939393939393939 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Scenarios for Use Cases

Use Case: Handle Session

Precondition: the ATM is free

Primary Scenario

1. The Customer inserts the card into the ATM.

2. The ATM verifies the cardvalidity.

3. The Customer authentifieswith the ATM.

4. The ATM gets the Customer information from the Bank.

5. The Customer selects a transaction.

6. The Customer quits.

7. The ATM ejects the card.

Postcondition: the ATM is free

Variants

2a The card is invalid; the ATM swallows it; this ends the session.

3a The Customer fails to authentify; the ATM swallows the card; this ends the session.

4a The connection with the Bank is impossible or interrupted; the ATM ejects the card; this ends the session.

5a The Customer may quit immediately.

6a The Customer chooses to perform another transaction; goto step 5.

* The Customer may cancel the session; the ATM ejects the card.

27/09/2011 4040404040404040 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Example of Secondary Scenarios

Use Case: Handle Session

Scenario: Secondary (customer

interrupt)

Precondition: the ATM is free

1. The scenario starts when

the customer inserts the

card

2. The card is accepted

3. The customer enters the

secret code correctly

4. The customer cancel the

session

5. The card is ejected and the

scenario is finished

Postcondition: the ATM is free

Page 21: UML1

21

27/09/2011 4141414141414141 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Use Case : Class Assignment

• We are currently facing a crisis in grading your midterms. We know the steps to do this, but can’t somehow figure out how it all works together.

• The TA’s create sample answers to the midterm. They also create a grading rubric. The professor then goes through both of them, and approves or makes necessary modifications.

• The reader then takes the approved sample answers and the grading rubric and grades the midterm. The

• TA’s finally collect the grades from the reader and enter them on the Glookup system.

27/09/2011 4242424242424242 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Use Case : Example of Secondary Scenarios

Page 22: UML1

22

27/09/2011 4343434343434343 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

Class Diagram

• Class diagram describes

– Types of objects in the system

– Static relationships among them

• Two principal kinds of static relationships

– Associations between classes

– Subtype relationships between classes

• Class diagrams represent the structure of the system.

• Used

– during requirements analysis to model problem domain concepts

– during system design to model subsystems and interfaces

– during object design to model classes.

27/09/2011 4444444444444444 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• 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 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?

Class Diagram

Page 23: UML1

23

27/09/2011 4545454545454545 / 160/ 160/ 160/ 160/ 160/ 160/ 160/ 160Dr. Farhana Jabeen

• What is a UML class diagram?

• What are some things that are not

represented in a UML class diagram?

Page 24: UML1
Page 25: UML1
Page 26: UML1
Page 27: UML1
Page 28: UML1
Page 29: UML1
Page 30: UML1
Page 31: UML1
Page 32: UML1
Page 33: UML1
Page 34: UML1
Page 35: UML1
Page 36: UML1
Page 37: UML1
Page 38: UML1
Page 39: UML1

ERROR: undefinedOFFENDING COMMAND: Pscript_WinNT_Min

STACK: