104
Actor Someone or something outside the system that interacts with the use cases developed for the system What

Actor Someone or something outside the system that interacts with the use cases developed for the system What

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Actor

Someone or something outside the system that interacts with the use cases developed for the system

What

Use case

A pattern of behavior the system exhibits.

It is a sequence of related transactions performed by an actor and the system in a dialogue.

What

Use case

–In general, a use case should cover the full sequence of steps from the beginning of a task until the end.

–A use case should describe the user’s interaction with the system ...

• not the computations the system performs.

–A use case should be written so as to be as independent as possible from any particular user interface design.

–A use case should only include actions in which the actor interacts with the computer.

What

Use Case Diagram

Use case diagrams present an outside view of the system.

The functionality of a use case is captured in its flow of events.

A use case diagram shows the relationships among actors and use cases within the system.

What

Extensions

–Used to make optional interactions explicit or to handle exceptional cases.

–By creating separate use case extensions, the description of the basic use case remains simple.

–A use case extension must list all the steps from the beginning of the use case to the end.

• Including the handling of the unusual situation.

What

Generalizations

–Much like superclasses in a class diagram. –A generalized use case represents several similar use cases.

–One or more specializations provides details of the similar use cases.

What

Inclusions

–Allow one to express commonality between several different use cases.

–Are included in other use cases• Even very different use cases can share sequence of

actions.• Enable you to avoid repeating details in multiple use

cases.

–Represent the performing of a lower-level task with a lower-level goal.

What

Example of generalization, extension and inclusion

Open file by typing name

Open file by browsing

Open file

System Administrator

Browse for file

Ordinary User

Attempt to open file that does not exist

«extend» «include»

Step 1: Identifying Actors• To fully understand the system's purpose

you must know who the system is for, that is, who will be using the system.

• Different user types are represented as actors.

• An actor is anything that exchanges data with the system.

• An actor can be a user, external hardware, or another system.

How

Actor and User (1/2)

• The difference between an actor and an individual system user is that an actor represents a particular class of user rather than an actual user. Several users can play the same role, which means they can be one and the same actor. In that case, each user constitutes an instance of the actor.

What

Actor and User (2/2)What

How to find Actors?

The following set of questions is useful to have in mind when you are identifying actors: – Who will supply, use, or remove information? – Who will use this functionality? – Who is interested in a certain requirement? – Where in the organization is the system used? – Who will support and maintain the system? – What are the system’s external resources? – What other systems will need to interact with this

one?

How

Actor DescriptionThe brief description of the actor should include information

about: – What or who the actor represents. – Why the actor is needed. – What interests the actor has in the system.

• The brief description should be, at most, a few sentences long.

Example:• Customer: The Customer collects bottles, cans and crates at

home and brings them back to the shop to get a refund.• Operator: The Operator is responsible for maintenance of the

recycling machine.• Manager: The Manager is responsible for questions about

money and the service the store delivers to the customers.

How

Actor Characteristics• The actor's scope of responsibility. • The physical environment in which the actor will be using

the system. • The number of users represented by this actor. • The frequency with which the actor will use the system.

In most cases, a rough estimate of the number of users and frequency of use will suffice.

• The actor's level of domain knowledge. • The actor's level of general computer experience. • Other applications that the actor uses. • General characteristics of the actors, such as level of

expertise (education), social implications (language), and age. These characteristics can influence details of the user interface, such as font and language.

What

How to Find Use Cases?Following is a set of questions that are useful when identifying use cases: • For each actor you have identified, what are the tasks in which the system

would be involved? • Does the actor need to be informed about certain occurrences in the

system? • Will the actor need to inform the system about sudden, external changes? • Does the system supply the business with the correct behavior? • Can all features be performed by the use cases you have identified? • What use cases will support and maintain the system? • What information must be modified or created in the system?

Use cases that are often overlooked, since they do not represent what typically are the primary functions of the system, can be of the following kind:

• System start and stop. • Maintenance of the system. For example, adding new users and setting up

user profiles. • Maintenance of data stored in the system. For example, the system is

constructed to work in parallel with a legacy system, and data needs to be synchronized between the two.

• Functionality needed to modify behavior in the system. An example would be functionality for creating new reports

How

Brief Description of Use Case• The brief description of the use case should reflect its

purpose. As you write the description, refer to the actors involved in the use case, the glossary and, if you need to, define new concepts.

Example:• Recycle Items: The user uses this machine to

automatically have all the return items (bottles, cans, and crates) counted, and receives a receipt. The receipt is to be cashed at a cash register (machine).

• Add New Bottle Type: New kinds of bottles can be added to the machine by starting it in ‘learning mode’ and inserting 5 samples just like when returning items. In this way, the machine can measure the bottles and learn to identify them. The manager specifies the refund value for the new bottle type.

What

Step 1 and 2: Documenting Actors and Use CasesActorPotentialMemberClubMemberClubMemberClubMemberClubMemberClubMemberPastMemberMarketing

Marketing

Marketing

Time

Time

Time

Time

Time

Use Case NameSUBMIT NEWSUBSCRIPTIONPLACE NEW MEMBERORDERMAKE ACCOUNT INQUIRY

MAKE PURCHASE INQUIRY

MAINTAIN MEMBER ORDER

SUBMIT CHANGE OFADDRESSSUBMITRESUBSCRIPTIONSUBMIT NEW MEMBERSUBSCRIPTION PROGRAMSUBMIT PAST MEMBERRESUBSCRIPTIONPROGRAMSUBMIT NEW PROMOTION

GENERATE QUARTERLYPROMOTION ANALYSISGENERATE QUARTERLYSALES ANALYSISGENERATE QUARTERLYMEMBERSHIP ANALYSISGENERATE ANNUAL SALESANALYSISGENERATE ANNUALMEMBERSHIP ANALYSIS

Use Case DescriptionPotential member joins the club by subscribing. (“Take anu 12 CDs for one penny and agree to buy 4 more at regular club prices within two years.”)Club member places order.

Club member wants to examine his or her account history.(90-day time limit)Club member inquires about his/her purchase history.(three-year time limit)Club member wants to revise an order or cancel an order.

Club member changes address.(including e-mail and privacy code)Past member rejoins the club by resubscribing.

Marketing establishes a new membership resubscription plan to entice new members.Marketing establishes a new membership resubscription plan to lure back former members.

Marketing initiates a promotion.(Note: A promotion features specific titles, usually new, that company is trying to sell at a special price. These promotions are integrated into a catalog sent (or communicated) to all members.)Print quarterly promotion analysis report.

Print annual sales analysis report.

Print annual membership analysis report.

Print annual sales analysis report.

Print annual membership analysis report.

How

Operations Subsystem

Order Subsystem

Promotion Subsystem

Subscription Subsystem

Submit PastMember

ResubscriptionProgram

Time Marketing

Past Member

Club Member

Potential Member

Generate AnnualSales Analysis

Generate AnnualMembership

Analysis

Generate QuarterlyMembership

Analysis

Generate QuarterlySales Analysis

Generate QuarterlyPromotion Analysis

Submit NewPromotion

Submit NewMember

SubscriptionProgram

SubmitResubscription

Submit Change ofAddress

Maintain MemberOrder

Make PurchaseInquiry

Make AccountInquiry

Place NewMember Order

Submit NewSubscription initiates

initiates

initiatesinitiates

initiatesinitiates

initiatesinitiates

initiates

initiates

initiates

initiates

initiates

initiates

initiates

Step 3: Constructing a Use Case Model How

Step 4: Describe the Use Cases

• The Flow of Events of a use case contains the most important information derived from use-case modeling work.

• It should describe the use case's flow of events clearly enough for an outsider to easily understand it.

• Remember the flow of events should present what the system does, not how the system is design to perform the required behavior.

What

Guidelines for Flow of Events• Describe how the use case starts and ends. • Describe what data is exchanged between the actor and the use case. • Do not describe the details of the user interface, unless it is necessary

to understand the behavior of the system. For example, it is often good to use a limited set of web-specific terminology when it is known beforehand that the application is going to be web-based. Otherwise, your run the risk that the use-case text is being perceived as too abstract. Words to include in your terminology could be "navigate", "browse", "hyperlink" "page", "submit", and "browser". However, it is not advisable to include references to "frames" or "web pages" in such a way that you are making assumptions about the boundaries between them - this is a critical design decision. 

• Describe the flow of events, not only the functionality. To enforce this, start every action with "When the actor ... ".

• Describe only the events that belong to the use case, and not what happens in other use cases or outside of the system.

• Avoid vague terminology such as "for example", "etc. " and "information".

• Detail the flow of events—all "whats" should be answered. Remember that test designers are to use this text to identify test cases.

How

Flow of Events: Structure

• The basic flow of events should cover what "normally" happens when the use case is performed.

• The alternative flows of events cover behavior of optional or exceptional character in relation to the normal behavior, and also variations of the normal behavior.

What

How to describe a single use case?

• Use case name: Give a short, descriptive name to the use case.• Actor(s): List the actors who can perform this use case. • Brief Description: Explain what the actor or actors are trying to achieve.• Preconditions: State of the system before the use case.• Basic Flow of Events: Describe the use case steps.• Alternative Flow of Events: Describe behavior of optional or exceptional steps.• Extension Points•Postconditions: State of the system in following completion.

How

Course Registration Example– At the beginning of each semester students may

request a course catalogue containing a list of course offerings for the semester. Information about each course, such as professor, department, and prerequisites will be included to help students make informed decisions.

– The new system will allow students to select four course offerings for the coming semester. In addition, each student will indicate two alternative choices in case a course offering becomes filled or canceled. No course offering will have more than ten students. No course offering will have fewer than three students. A course offering with fewer than three students will be canceled. Once the registration process is completed for a student, the registration system sends information to the billing system so the student can be billed for the semester.

Course Registration Example– Professors must be able to access the on-line

system to indicate which courses they will be teaching. They will also need to see which students signed up for their course offerings.

– For each semester, there is a period of time that students can change their schedule. Students must be able to access the system during this time to add or drop courses.

Actors in the Course Registration Example

– The actors are• Student• Professor• Billing System• Registrar

Who

Use Cases

– Student• Register for courses

– Registrar• Maintain course information, Maintain student

information, Maintain professor information, Generate catalogue

– Professor• Request course roster, Select courses to teach

What

Use Case Diagram

Student

Billing System

Register for CoursesRequest Course Roster

Select Courses to Teach

Professor

Maintain Student Info

Maintain Professor Info Maintain Course Info

Generate Catalogue

Registrar

What

Brief Description -- Register for Courses Use Case

– This use case is initiated by a student. It provides the capability for the student to create, delete, modify and/or review a course schedule for a given semester.

What

Flow of Events -- Register for Courses Use Case This use case begins when the student enters the student id number. The system verifies that the student id number is valid and prompts the student to select the current semester or a future semester. The student enters the desired semester. The system prompts the student to select the desired activity:

Create a schedule Review a schedule Change a schedule

Delete a course Add a course

The student indicates that the activity is complete. The system will print the student schedule and notify the student that registration is complete. The system sends billing information for the student to the billing system for processing.

What

Flow of Events -- Register for Courses Use Case– Alternate flow If an invalid id number is entered, the system will not allow access to the registration system. If an attempt is made to create a schedule for a semester where a schedule already exists the system will prompt for another choice to be made.

– Create a schedule The student enters 4 primary course offering numbers and 2 alternate course offering numbers. The student then submits the request for courses. The system then

1: Checks that prerequisites are satisfied for the requested course 2: Adds the student to the course offering if the course offering is

open. Alternate flow If a primary course offering is not available, the system will substitute an alternate course offering.

What

Flow of Events -- Register for Courses Use Case– Review a Schedule

The student requests information on all course offerings in which the student is registered for a given semester. The system displays all course offerings for which the student is registered including course name, course number, course offering number, days of the week, time, location, and number of credit hours.

– Change Schedule -- Delete a Course Offering The student indicates which course offering to delete. The system checks that the final date for changes has not been exceeded. The system deletes the student from the course offering. The system notifies the student that the request has been processed.

What

Flow of Events -- Register for Courses Use Case

Change Schedule -- Add a Course The student indicates which course offerings to add. The system checks that the final date for changes has not been exceeded. The system then 1: Verifies that the maximum course load for the student has not been exceeded 2: Checks that prerequisites are satisfied for the requested course

3: Adds the student to the course offering if the course offering is open.

What

(124-93 يدهاي مدرس ) اساليراهنما

، اج�زاء Class Diagram و Class Modelingدر اين مجموع�ه، بررس� م�ورد آن نح�وه س�اخت و ق�رار ميو مراح�ل گيرن�د.ي

ن منظوريبداس�ال نماده�ا109-93يدهايدر : اص�لي Class Diagram ي

شوند.يح داده ميح و با مثال توضي شده و به تشريمعرفاسال قدمها124-110 يدهايدر اصلي: ساخت ي Class

Diagramشوند.ي شده و با مثال شرح داده مي معرف

Classes

•A class is simply represented as a box with the name of the class inside –The diagram may also show the attributes and operations

–The complete signature of an operation is: operationName(parameterName: parameterType …): returnType

Rectangle

height: intwidth: int

getArea(): intresize(int,int)

Rectangle

heightwidth

getArearesize

Rectangle

heightwidth

Rectangle

getArearesize

Rectangle

How

Associations and Multiplicity

•An association is used to show how two classes are related to each other–Symbols indicating multiplicity are shown at each end of the association

0,3..8 ******

Employee

*

* *****1..*

*0..1

Secretary

Office

Person

Company

Employee Company

Manager

BoardOfDirectors

BoardOfDirectors

What

Labelling associations

–Each association can be labelled, to make explicit the nature of the association

*

supervisor

*****1..*

* worksFor

*allocatedTo0..1

boardMember

0,3..8 ******

Employee

Secretary

Office

Person

Company

Employee Company

Manager

BoardOfDirectors

BoardOfDirectors

How

Analyzing and validating associations

–Many-to-one• A company has many employees, • An employee can only work for one company.

– This company will not store data about the moonlighting activities of employees!

• A company can have zero employees– E.g. a ‘shell’ company

• It is not possible to be an employee unless you work for a company

* worksForEmployee Company

Which

Analyzing and validating associations

–Many-to-many• A secretary can work for many managers• A manager can have many secretaries• Secretaries can work in pools• Managers can have a group of secretaries• Some managers might have zero secretaries. • Is it possible for a secretary to have, perhaps

temporarily, zero managers?*

supervisor

*****1..*Secretary Manager

Which

Analyzing and validating associations

–One-to-one• For each company, there is exactly one board of

directors• A board is the board of only one company• A company must always have a board• A board must always be of some company

Company BoardOfDirectors

Which

Analyzing and validating associations

•Avoid unnecessary one-to-one associations

• Avoid this do thisPerson

nameaddressemailbirthdate

Person

name

PersonInfo

addressemailbirthdate

How

A more complex example

–A booking is always for exactly one passenger • no booking with zero passengers• a booking could never involve more than one

passenger.

–A Passenger can have any number of Bookings• a passenger could have no bookings at all• a passenger could have more than one booking

************Passenger SpecificFlightBooking

Association classes

–Sometimes, an attribute that concerns two associated classes cannot be placed in either of the classes

–The following are equivalent

Registration

grade

Student CourseSection* ******

Registration

grade

Student CourseSection* *

What

Reflexive associations

–It is possible for an association to connect a class to itself

Course *isMutuallyExclusiveWith

*

*

prerequisite

successor *

How

Directionality in associations

–Associations are by default bi-directional –It is possible to limit the direction of an association by adding an arrow at one end

** NoteDay

How

Aggregation

–Aggregations are special associations that represent ‘part-whole’ relationships.

• The ‘whole’ side is often called the assembly or the aggregate

• This symbol is a shorthand notation association named isPartOf

****

****** Region

VehiclePart

Country

Vehicle

What

When to use an aggregation

•As a general rule, you can mark an association as an aggregation if the following are true: –You can state that

• the parts ‘are part of’ the aggregate

• or the aggregate ‘is composed of’ the parts

–When something owns or controls the aggregate, then they also own or control the parts

When

–A composition is a strong kind of aggregation • if the aggregate is destroyed, then the parts are

destroyed as well

–Two alternatives for addresses

Composition

***** RoomBuilding

EmployeeEmployeeaddress: Address

AddressstreetmunicipalityregioncountrypostalCode

What

Generalization

•Specializing a superclass into two or more subclasses–The discriminator is a label that describes the criteria used in the specializationAnimal Animal

habitat typeOfFood

HerbivoreCarnivoreLandAnimalAquaticAnimal

What

Avoiding unnecessary generalizations

RockRecordingBluesRecordingClassicalRecordingJazzRecordingMusicVideo

VideoRecoding AudioRecording

Recording

rockbluesclassicaljazzmusic video

video audio

RecordingCategory*subcategorydescription

Recording *hasCategory

subcategory subcategorysubcategorysubcategorysubcategory

:RecordingCategory :RecordingCategory

:RecordingCategory :RecordingCategory :RecordingCategory :RecordingCategory:RecordingCategory

9th Symphony

:Recording

Let it be

:Recording

The BeatlesBeethoven

titleartist

Inappropriate hierarchy ofclasses, which should beinstances

Improved class diagram,with its correspondinginstance diagram

How

Use Case with Nouns HighlightedUSE CASE NAME:ACTOR(S):DESCRIPTION:

REFERENCESTYPICAL COURSE OF EVENTS:

Author: S. Shepherd Date: 10/25/2000ANALYSIS USE CASE

Place New Member OrderClub MemberThis use case describes the process of a club member submitting a new order for SoundStage products. On completion, the club member will be sent a notification that the order was accepted.MSS-1.0

Actor Action

Step 1: This use case is initiated when a member submits an order to be processed.

Step 9: This use case concludes when the member receives the order confirmation notice.

System Response

Step 2: The member’s personal information such as address and phone number is validated against what is currently on file.Step 3: For each product being ordered, validate the product number.Step 4: For each product being ordered, check the availability in inventory and record the ordered product information such as the quantity being ordered.Step 5: Invoke extension use case Calculate Order Subtotal & Sales Tax.Step 6: The member’s credit card information is verified based on the amount due and Accounts Receivable transaction data is checked to make sure no payments are outstanding.Step 7: Invoke extension use case Generate Warehouse Packing Order.Step 8: Generate an order confirmation notice indicating the status of the order and send it to the member.

(continued)

Use Case with Nouns Highlighted (concluded)

ALTERNATECOURSES:

PRECONDITION:

POSTCONDITION:

ASSUMPTIONS:

Step 2: If the club member has indicated an address or telephone number change on the order, invoke abstract use case Revise Street Address.Step 3: If the product number is not valid, send a notification to the member requesting the member to submit a valid product number.Step 4: If the product being ordered is not available, record the ordered product information and mark the order as “backordered.”Step 6: If member’s credit card information is invalid or if member is found to be in arrears, a credit problem notice is sent to the member. Modify the order’s status to be “on hold pending payment.”

Orders can only be submitted by members.

Member order has been recorded and the Packing Order has been routed to the Warehouse.

None at this time.

Potential Objects Extracted from Use CasePOTENTIAL OBJECT LISTAccounts Receivable DepartmentAmount Due Club Member Credit Card InformationCredit Problem NoticeCredit Status File Marketing DepartmentMember AddressMember OrderMember Phone NumberMember Services DepartmentMember Services SystemOrder Order Confirmation NoticeOrder Sales TaxOrder Status Order SubtotalOrdered ProductOrdered Product InformationOrdered Product QuantityPast Member Payments Potential MemberProduct Product InventoryProduct NumberStreet Address Transaction Warehouse Warehouse Packing Order

What

Analysis of the Potential ObjectsPOTENTIAL OBJECT LISTAccounts Receivable DepartmentAmount Due Club Member Credit Card InformationCredit Problem NoticeCredit Status File Marketing DepartmentMember AddressMember OrderMember Phone NumberMember Services DepartmentMember Services SystemOrder Order Confirmation NoticeOrder Sales TaxOrder Status Order SubtotalOrdered ProductOrdered Product InformationOrdered Product QuantityPast Member Payments Potential MemberProduct Product InventoryProduct NumberStreet Address Transaction Warehouse Warehouse Packing Order

Not relevant for current project Attribute of “MEMBER ORDER” Type of “MEMBER” Attribute of “MEMBER”

Potential Interface item to be addressed in object-oriented design Attribute of “MEMBER” Not relevant for current project Not relevant for current project Attribute of “MEMBER” “MEMBER ORDER” Attribute of “MEMBER”

Not relevant for current project

Not relevant for current project

Another name for “MEMBER ORDER”

Potential Interface item to be addressed in object-oriented design Attribute of “MEMBER ORDER” Attribute of “MEMBER ORDER”

Attribute of “MEMBER ORDER”

“MEMBER ORDERED PRODUCT”

Unclear noun

Attribute of “MEMBER ORDERED PRODUCT” Type of “MEMBER” Type of “TRANSACTION” Type of “MEMBER”

“PRODUCT”

Attribute of “PRODUCT”

Attribute of “PRODUCT”

Attribute of “MEMBER”

“TRANSACTION”

Not relevant for current project

Potential Interface item to be addressed in object-oriented design

REASONxx

xxxxxx

xxxxxxxx

xx

xxx

xx

/

////

/

/

/

Results of AnalysisPROPOSED OBJECT LISTCLUB MEMBER

MEMBER ORDERMEMBER ORDERED PRODUCTPAST MEMBERPAYMENTPOTENTIAL MEMBERPRODUCTTRANSACTION

AGREEMENTAUDIO TITLE

MERCHANDISE

GAME TITLEPROMOTION

RETURNTITLEVIDEO TITLE

-- PLUS --

Constructing a Class Diagram

• Step 1: Identify Associations and Multiplicity– Underlining (or highlighting) the use case nouns

• Step 2: Identify Generalization/Specialization Relationships

• Step 3: Identify Aggregation Relationships• Step 4: Prepare the Class Diagram

How

<<actor>>Club Member

Member-Date-Of-Last-OrderMember-Daytime-Phone-NumberMember-Credit-Card-Expire-DateMember-Credit-Card-NumberMember-Credit-Card-TypeMember-Balance-DueMember-Bonus-Balance-AvailableAudio-Category-PreferenceAudio-Media-PreferenceDate-EnrolledEmail-AddressGame-Category-PreferenceGame-Media-PreferenceNumber-Of-Credits-EarnedPrivacy-CodeVideo-Category-PreferenceVideo-Media-Preference

persistent

Member Order

Order-NumberOrder-Creation-DateOrder-Fill-DateShipping-Address-NameShipping-Street-AddressShipping-CityShipping-StateShipping-Zip-CodeShipping-InstructionsOrder-Sub-TotalOrder-Sales-TaxOrder-Shipping-MethodOrder-Shipping-&-Handling-CostOrder-StatusOrder-Prepaid-AmountOrder-Prepayment-Method

persistent

Product

Product-NumberUPC-Quantity-In-StockProduct-TypeSuggested-Retail-PriceDefault-Unit-PriceCurrent-Special-Unit-PriceCurrent-Month-Units-SoldCurrent-Year-Units-SoldTotal-Lifetime-Units-Sold

persistent

Video Title

ProducerDirectorVideo-CategoryVideo-Sub-CategoryClosed-CaptionedLanguageRunning-TimeVideo-Media-TypeVideo-EncodingScreen-AspectMPA-Rating-Code

persistent

Audio Tilte

ArtistAudio-CategoryAudio-Sub-CategoryNumber-Of-Units-In-PackageAudio-Media-CodeContent-Advisory-Code

persistent

Transaction

Transaction-Reference-NumberTransaction-DateTransaction-TypeTransaction-DescriptionTransation-Amount

persistent

Member

Member-NumberMember-NameMember-StatusMember-Street-AddressMember-PO-BoxMember-CityMember-StateMember-Zip-Code

persistent

Agreement

Agreement-NumberAgreement-Expire-DateAgreement-Active-DateFulfillment-PeriodRequired-Number-Of-Credits

persistent

Game Title

ManufacturerGame-CategoryGame-Sub-CategoryGame-PlatformGame-Media-TypeNumber-Of-PlayersParent-Advisory-Code

persistent

Title

Title-Of-WorkTitle-CoverCatalog-DescriptionCopyright-DateEntertainment-CompanyCredit-Value

persistent

Member Ordered Product

Quantity-OrderedQuantity-ShippedQuantity-BackorderedPurchase-Unit-PriceCredits-Earned

persistent

Merchandise

Merchandise-NameMerchandise-DescriptionMerchandise-TypeUnit-of-Measure

persistent

Promotion

Promotion-NumberPromotion-Release-DatePromotion-StatusPromotion-Type

persistent

<<actor>>Potential Member

persistent

<<actor>>Past Member

Expiration-Date

persistent

Return

persistent

1..*

1binds

1

0..*

Conducts

1

0..*

Haspurchased

0..10..*

Generates

0..*

1..*

Features

1

0..*

Sold as

0..*

1

Places

1

1..*

Sells

Member Services System Class Diagram

(Figure A.15, page 667)

The “Register for Courses” Scenario Nouns

– John Student ID number 369523449– System Number– Semester Current semester– New schedule List of available courses– Primary courses English 101– Geology 110 World History 200– College Algebra 110 Alternate courses– Music Theory 110 Introduction to Java Programming 180– Necessary prerequisitesCourse roster– Activity Student schedule– Billing information Four courses– Billing system

What nouns should be filtered ?What nouns should be filtered ?

Filtering Decisions

– John -- filtered (actor)– Student ID number 369523449 -- filtered (property of a student)– System -- filtered (what is being built)

– Number -- filtered (same as student ID number)– Semester -- filtered (state -- when the selects apply)

– Current semester -- filtered (same as semester)– New schedule -- candidate object– List of available courses -- candidate object– Primary courses -- filtered (state of a selected course)

– English 101 -- candidate object– Geology 110 -- candidate object

Filtering Decisions– World History 200 -- candidate object– College Algebra 110 -- candidate object – Alternate courses -- filtered (state of a selected course)

– Music Theory 110 -- candidate object – Introduction to Java Programming 180 -- candidate object– Necessary prerequisites -- candidate object– Course roster -- candidate object– Activity -- filtered (English expression)

– Student schedule -- filtered (same as new schedule)– Billing information -- candidate object – Four courses -- filtered (information needed by billing

information)– Billing system -- filtered (actor)

Candidate Objects– New schedule -- list of courses for a semester for a student– List of available courses -- list of all courses being taught in a

semester– English 101 -- an offering for a semester– Geology 110 -- an offering for a semester– World History 200 -- an offering for a semester– College Algebra 110 -- an offering for a semester

– Music Theory 110 -- an offering for a semester– Introduction to Java Programming 180 -- an offering for a

semester – Necessary prerequisites -- a list of courses that must be taken

before another course – Course roster -- list of students for a specific course offering

– Billing information -- information needed by the billing system actor

-126 يدهاي مدرس ) اساليراهنما144)

State ارائه شده در اين قسمت، يدر مجموعه اساليدهاTransition Diagram و Behavioral Modeling و

بررس� م�ورد آنه�ا س�اخت نح�وه و اج�زاء و يمف�اهيم ن منظوري بد. گيرديقرار م

130-126 يدهايدر اس�ال : State Transition Diagram نح�وه ، ه�ا و State آن و ارتباط�ات بين ي ه�اAttribute و Stateنم�ايش

شوند.ي مي ها بررسStateانواع خاص اسال در 138-131 يدهايدر مفاهيم ديگر :State Transition

Diagram ش��امل Event، Transition، Action، Activity و Nested Stateشوند.ي مي بررس

مثال آورده شده است.140-139 يدر اساليدها 144-141 يدر اس�اليدها :Behavioral Model و مراح�ل س�اخت

State Machine Diagram.با يک مثال ذکر شده اند

Drawing States– A state is represented as a rounded rectangle

on a state transition diagram (STD)

State Name

How

State and Attributes

numStudents < 10

– States may be distinguished by the values of certain attributes

Open

The maximum number of students per course is 10

numStudents > = 10

Closed

numStudents = 7

English101 : CourseCourse

numStudents

How

States and Links– States may also be distinguished by the

existence of certain links– Instances of class Professor can have two

states:• Teaching when a link to a course exists• On sabbatical when no link exists

John:Professor Biology:Course

How

Special States

– The start state is the state entered when an object is created

• A start state is mandatory• Only one start state is permitted • The start state is represented as a solid circle

– A stop state indicates the end of life for an object

• A stop state is optional• More than one stop state may exist• A stop state is indicated by a bull’s eye Stop stateStart state

What

Events

– An event is an occurrence that happens at some point in time

• The state of the object determines the response to different events

– Example:• Adding a student to a course• Creating a new course

What

Transitions– A transition is a change from an originating state to a successor state as a result of some stimulus

• The successor state could possibly be the originating state

– A transition may take place in response to an event

– Transitions can be labeled with eventsOpen CanceledCancel course

Add student

What

Guard Conditions– A guard condition is a Boolean expression of

attribute values which allows a transition only if the condition is true

Open

Add student[ numStudents < 10 ]

ClosedAdd student[ numStudents = 10 ]

What

Actions– An action is an operation that is associated with

a transition• Takes an insignificant amount of time to complete • Considered to be non-interruptible

– Action names are shown on the transition arrow preceded by a slash

Creation Open

Registration open / Initialize numStudents to 0

Add student[ numStudents < 10 ]

What

Activities

– An activity is an operation that takes time to complete

– Activities are associated with a state– An activity

• Starts when the state is entered• Can run to completion or can be interrupted by

an outgoing transitionClosed

do: Report course is full

What

Automatic Transitions

– Sometimes, the sole purpose of a state is to perform an activity

– An automatic transition occurs when the activity is complete

– If there are multiple automatic transitions• A guard condition is needed on each transition• The conditions must be mutually exclusiveClosed

do: finalize course

Offered

What

Entry and Exit Actions

– When an action must occur no matter how a state is entered or exited, the action can be associated with the state

• In reality, the action is associated with every transition entering or exiting the state

– The action is shown inside the state icon preceded by the keyword entry or exit

Unassigned

do: Assign professor to course

/ numStudents = 0 Open

entry: Register a student

addStudent [ numStudents < 10]

What

Nested States– State transition diagrams can become

unmanageably large and complex– Nested states may be used to simplify

complex diagrams– A superstate is a state that encloses nested

states called substates– Common transitions of the substates are

represented at the level of the superstate– Any number of levels of nesting is permitted– Nested states can lead to substantial

reduction of graphical complexity, allowing us to model larger and more complex problems

What

State Transition Diagram for the Course Class Without Nested States

Initialize

do: Initialize course object

Unassigned

do: Assign professor to course

Open

entry: Register a student

Closed

do: Report course is full

Canceled

do: Send cancellation notices

addStudent/ numStudents = 0

cancelCourse

RegistrationComplete

do: Generate class roster

InsufficientStudents

do: Drop all students registered

cancelCourse

[ numStudents = 10 ]

cancelCourse

registrationComplete[ numStudents > = 3 ]

addStudent [numStudents < 10]

registrationComplete[

numStudents < 3 ]

How

State Transition Diagram for the Course Class With Nested States

Initialize DoneInitializing

Unassigned

do: Assign professor to course

Open

entry: Register a student

Closed

Unassigned

do: Assign professor to course

Open

Closed Canceled

RegistrationComplete

do: Generate class roster

InsufficientStudents

do: Drop all students registered

Add student / numStudents = 0

[ numStudents = 10 ]

cancelCourse

registrationComplete[ numStudents > = 3 ]

registrationComplete[ numStudents < 3 ]

addStudent [numStudents < 10]

How

Order Shipped

Order Released Order Filled

Order Invoiced

PendingIn Process

Order Backordered

Order ClosedMember Order final

state

Member Order finalstate

Member Order initial state

Order pending awaiting payment or additional member information

Order rejected based on Member's past history

Member order archived after 90 days

Invoice sent to member for payment

Response received from member

Order released to the warehouse

Order shipped to club member

Order filled by the warehouse

Not all product available

Final payment received

Order submitted

Product received

Member Order State Diagram

-146 يدهاي مدرس ) اساليراهنما177)

ي ش�ده و نح�وه ش�رح آن بررس�ي مع�رفPatternدر اين مجموع�ه، ن منظوري ب�د. گيرن�دي ق�رار مي م�ورد بررس�Patternش�ده و ان�واع

147 و 146 يدهايدر اس�ال : Patternش�ده و نح�وه توص�يف ي مع�رف .آن آورده شده است

151-148 يدهايدر اس�ال :Abstraction Occurrence Patternش�ده ي مع�رف است.

154-152 يدر اس�اليدها :General Hierarchy Patternش�ده است.ي مع�رف 159-155 يدر اس�اليدها :Player Role Patternش�ده است.ي ب�ا مث�ال مع�رف 161 و 160 يدر اساليدها :Singleton Patternشده است.ي معرف 164-162 يدر اساليدها :Observer Patternشود.ي ارائه م 168-165 يدر اساليدها :Delegation Patternشده است.ي معرف 171-169 ياساليدها :Adapter Pattern.را شرح داده است به 173و 172 ياساليدها Façade Pattern.اختصاص داده شده است 174در اساليد ،Immutable Patternشده است.ي معرف به 177-175 يو اساليدها Proxy Pattern پردازند.ي م

The Abstraction-Occurrence Pattern

–Context: • Often in a domain model you find a set of related objects

(occurrences).• The members of such a set share common information

– but also differ from each other in important ways.

–Problem: • What is the best way to represent such sets of occurrences in a

class diagram?

–  Forces: • You want to represent the members of each set of occurrences

without duplicating the common information

What

Abstraction-Occurrence

–Solution:

TVSeries

seriesNameproducer

Episode

numbertitle

storySynopsis

******

«Occurrence»«Abstraction» ******

Title

nameauthor

LibraryItem

barCodeNumber******

isbnpublicationDatelibOfCongress

What

Abstraction-Occurrence

•Antipatterns:

nameauthor

LibraryItem

barCodeNumber

isbnpublicationDatelibOfCongress

Title

nameauthor

LibraryItem

barCodeNumber

isbnpublicationDatelibOfCongress

nameauthor

LibraryItem

barCodeNumber

isbnpublicationDatelibOfCongress

GulliversTravels MobyDick

What

Abstraction-Occurrence

•Square variantScheduledTrain

number

SpecificTrain

date**

* *

ScheduledLeg SpecificLeg

actualDepTime*

actualArrTimescheduledDepTimescheduledArrTime

Station

origin destination* *

What

The General Hierarchy Pattern–Context:

• Objects in a hierarchy can have one or more objects above them (superiors),

– and one or more objects below them (subordinates).

• Some objects cannot have any subordinates

–Problem: • How do you represent a hierarchy of objects, in which

some objects cannot have subordinates?

–Forces: • You want a flexible way of representing the hierarchy

– that prevents certain objects from having subordinates

• All the objects have many common properties and operations

What

General Hierarchy

–Solution:«subordinate»*«Node»

«SuperiorNode»«NonSuperiorNode»

* supervises

Manager

Employee

TechnicianSecretary

0..1

0..1

* contains

Directory

FileSystemItem

File

0..1

What

General Hierarchy

•Antipattern:

RockRecordingBluesRecordingClassicalRecordingJazzRecordingMusicVideo

VideoRecoding AudioRecording

Recording

What

The Singleton Pattern

–Context: • It is very common to find classes for which only one

instance should exist (singleton)

–Problem: • How do you ensure that it is never possible to create

more than one instance of a singleton class?

–Forces: • The use of a public constructor cannot guarantee that

no more than one instance will be created. • The singleton instance must also be accessible to all

classes that require it

What

Singleton

–Solution:

Company

theCompany

Company «private»getInstance

if )theCompany==null( theCompany= new Company)(;

return theCompany;

«Singleton»

theInstance

getInstance

What

The Observer Pattern

–Context: • When an association is created between two classes,

the code for the classes becomes inseparable. • If you want to reuse one class, then you also have to

reuse the other.

–Problem: • How do you reduce the interconnection between

classes, especially between classes that belong to different modules or subsystems?

–Forces: • You want to maximize the flexibility of the system to

the greatest extent possible

What

Observer

–Solution:

WeatherViewer

* ******

Observers are notified when a new prediction is readyForecaster

Observable

«ConcreteObservable» «ConcreteObserver»

«Observable»

addObservernotifyObservers

«interface»«Observer»

update

* ****** «interface»Observer

What

Observer

•Antipatterns:–Connect an observer directly to an observable so that they both have references to each other.

–Make the observers subclasses of the observable.

What

The Delegation Pattern

–Context: • You are designing a method in a class• You realize that another class has a method which

provides the required service • Inheritance is not appropriate

– E.g. because the isa rule does not apply

–Problem: • How can you most effectively make use of a method

that already exists in the other class?

–Forces: • You want to minimize development cost by reusing

methods

What

Delegation

–Solution:

LinkedList

addFirstaddLastaddAfterremoveFirstremoveLastdeleteisEmpty

Stack

pushpopisEmpty

«Delegate»«Delegator»delegatingMethod()

{ delegate.method();

} delegatingMethod method

push() {

list.addFirst(); }

What

DelegationExample:

****** SpecificFlightBooking

flightNumber() flightNumber()

RegularFlight

flightNumber()

*

flightNumber()

return specificFlight.flightNumber();

}

{ flightNumber()

return regularFlight.flightNumber();

}

{

What

Delegation

•Antipatterns–Overuse generalization and inherit the method that is to be reused

–Instead of creating a single method in the «Delegator» that does nothing other than call a method in the «Delegate

• consider having many different methods in the «Delegator» call the delegate’s method

–Access non-neighboring classesreturn specificFlight.regularFlight.flightNumber();

return getRegularFlight().flightNumber();

What

The Adapter Pattern

–Context: • You are building an inheritance hierarchy and want to

incorporate it into an existing class. • The reused class is also often already part of its own

inheritance hierarchy.

–Problem: • How to obtain the power of polymorphism when reusing a class

whose methods– have the same function– but not the same signature

as the other methods in the hierarchy?

–Forces: • You do not have access to multiple inheritance or you do not

want to use it.

What

Adapter

–Solution:

«Adaptee»

adaptedMethod

«Superclass»

polymorphicMethod

«Adapter»

polymorphicMethod()

return adaptee.adaptedMethod();

{

}

What

Adapter

•Example:

TimsTorus

calcVolume

ThreeDShape

volume

Sphere Torus

volume()

return adaptee.calcVolume();

{

}

What

The Façade Pattern

–Context: • Often, an application contains several complex packages. • A programmer working with such packages has to manipulate

many different classes

–Problem: • How do you simplify the view that programmers have of a

complex package?

–Forces: • It is hard for a programmer to understand and use an entire

subsystem • If several different application classes call methods of the

complex package, then any modifications made to the package will necessitate a complete review of all these classes.

What

Façade

–Solution:

«PackageClass3»

«PackageClass2»

«PackageClass1»

****** RegularFlight

******Person

Airline

findFlightmakeBookingdeleteBooking

«Facade»

What

The Immutable Pattern

–Context: • An immutable object is an object that has a state that never changes

after creation

–Problem: • How do you create a class whose instances are immutable?

–Forces: • There must be no loopholes that would allow ‘illegal’ modification of

an immutable object

– Solution: • Ensure that the constructor of the immutable class is the only place

where the values of instance variables are set or modified. • Instance methods which access properties must not have side

effects. • If a method that would otherwise modify an instance variable is

required, then it has to return a new instance of the class.

What

The Proxy Pattern

– Context: • Often, it is time-consuming and complicated to create instances of a

class (heavyweight classes). • There is a time delay and a complex mechanism involved in creating

the object in memory

–Problem: • How to reduce the need to create instances of a heavyweight class?

–Forces: • We want all the objects in a domain model to be available for

programs to use when they execute a system’s various responsibilities.

• It is also important for many objects to persist from run to run of the same program

What

Proxy

–Solution:

«interface»«ClassIF»

* ******«Client» «HeavyWeight»«Proxy»

What

Proxy

•Example:

«interface»ListIF

The list elements will be loaded into local memory only when needed.

ListProxy PersistentList

«interface»Student

PersistentStudentStudentProxy

What

-179 يدهاي مدرس ) اساليراهنما180)

ريسکها اساليد دو اين ايجاد يدر در موجود Class Diagramراه حله�ا و بررس�ي م�ورد آنه�ا ق�رار مي ي

گيرند.

پاسخ به پرسشها:

چه؟ ييعن يمدلساز1.

يدر چه موارد Object Oriented يروشها2.شوند؟ ياستفاده م

چيست؟ Object Oriented تحليل يمزايا3.

.4UML چيست؟

کدامند؟ UML يانواع دياگرامها5.

.6Use Case چيست؟

چيست؟ Composition مفهوم7.

State Machine Diagram مراحل ساخت8..را بيان کنيد

.9Pattern چيست؟