Vous êtes sur la page 1sur 11

Object-Oriented Analysis and DesignStandard Solutions

Craig Larman, 1998

Standard Solution: Use Cases


1. Identify at least 4 primary use cases and related actors. Draw the results in a UML use case diagram.

Q u e ry F o r V id e o s

P a y F in e s

R e n t V id e o s

M anage M e m b e r s h ip s C le r k L o g In C u s to m e r

M a n a g e V id e o s M anager M a n a g e U s e rs A d m in is t r a t o r

2. Write the Rent Videos use case in expanded, essential, conversational style. Include both a typical course of events, and an alternatives section. In the alternatives section, list exactly two frequent alternatives. Do not write an elaborate heading section for the use case (i.e., ignore Purpose, Overview, ); rather, start immediately with the typical course of events.
Use Case: Rent Videos

Essential, Expanded, Conversational Style Typical Course of Events Actor Actions 1. 2. This use case begins when a Customer arrives at a checkout with videos to rent. The Customer presents their membership identification to the Clerk, who enters it into the system. For each video, the Clerk records the item identification into the system. Clerk informs Customer of total rental fee, and asks for payment. Customer pays cash to Clerk. Clerk records payment into system. 9. Generates receipt and loan report. 3. Presents membership information, and status of loans (usually nothing on loan, and no outstanding fines). Presents accumulating list of rental video titles, due dates, and total rental fee. System Response

4. 6. 7. 8.

5.

10. Clerk gives receipt and loan report to Customer, who then leaves with the rental items. Alternatives Step 3: Customer has unpaid fines. Customer must pay them before proceeding with the loan. Step 6. Customer has insufficient cash. Cancel transaction or deduct rental items until transaction can be paid for.

Standard Solution: Conceptual Modeling


3. Bounded by the provided Rent Videos use case, create a conceptual model and illustrate it in UML notation. Show concepts, associations, and attributes.
P a y s - fo r- o v e r d u e - c h a r g e s

V id e o R e n ta l C a shP a ym e nt a m o u n t : Q u a n t ity 1 P a y s -fo r 1 1 d a te R e n ta lT r a n s a c tio n 1 1 1 .. * d u e D a te r e tu r n D a te r e t u r n T im e

*
I n it i a t e s 1 1 C u s to m e r a d d re s s na m e phoneNum b er R e n ts -fr o m R e n ts V id e o S t o r e a d d re s s nam e p ho ne N um b e r 1 M e m b e r s h ip ID s ta r tD a te I d e n t if i e s - r e n t e r -o f 1

1 ..* S to c k s 1 V id e o ID I s - r e c o r d e d - in

* * *
1 S t o r a g e M e d iu m d e s c r ip t i o n

1 O w n s -a 1 C a t a lo g 1 D e s c r ib e d - b y 1 .. *

L o a n P o li c y p e r D a y R e n ta lC h a r g e p e rD a y L a te C h a rg e 1 .. * 1 D e f in e s 1 ..*

V id e o D e s c r i p t i o n t it le s u b je c t C a t e g o r y D e t e r m in e s - r e n t a l- c h a r g e I n f lu e n c e s - c h a r g e

Standard Solution: System Events


4. Bounded by the provided Rent Videos use case, create a system sequence diagram in the UML notation. Show actors and system events.
R e n t V id e o s

C le r k

: S y s te m

c o n f ir m M e m b e r s h ip ( m e m b e r I D )

r e c o r d V i d e o R e n t a l( v id e o I D )

m a k e P a y m e n t( a m o u n t)

Standard Solution: Operation Contracts


Notes Although these contracts are not meant to be misleading, they may or may not be complete. Use your judgement to add postconditions or responsibilities, as necessary. Include an explanation of any additions. In subsequent analysis and during the design phase, we are not bound to the original definition of the conceptual model it was simply a starting point of inspiration. If we discover the need for new concepts, attributes, or associations, these may be added during the creation of contracts or collaboration diagrams. Similarly, original elements in the conceptual model may not be relevant in later work. Contract Name: Responsibilities: Cross References: Preconditions: Postconditions: If the membership was valid: A RentalTransaction txn was created and initialized. The Membership (with membershipID) was associated with txn. confirmMembership (membershipID) Confirm that the membership is validthat it exists, and that the membership is not suspended. Present confirmation. Present any overdue rentals and charges owed. Use Case: Renting Videos System does not have a rental transaction underway.

Contract Name: Responsibilities: Cross References: Preconditions: Postconditions: A VideoRental, vr, was created and initialized. vr was associated with a Video, based on videoID match. vr was associated with the current RentalTransaction. recordVideoRental (videoID) Record the rental of a video and add it to ongoing rental transaction. Present the item title, charge, and due date. Use Case: Renting Videos videoID is known to system. A RentalTransaction has been created.

Standard Solution: Responsibility Assignment and Collaboration Design


5. Using the confirmMembership operation contract as a starting hint, complete the UML collaboration diagram. Annotate every message with the GRASP (Expert, Creator, and so on) and/or other pattern that justifies it.

b y E x p e rt r e t u r n s " n u ll" if n o t a m e m b e r b y C o n t r o lle r

c o n f i r m M e m b e r s h i p ( m e m b e r s h ip I D )

: R e n tV id e o s H a n d le r

1 : m : = g e t M e m b e r s h ip ( m e m b e r s h i p I D ) : M e m b e r s h ip : V id e o S t o r e

2 : [ is M e m b e r ] c r e a t e ( m )

b y C re a to r

1 . 1 : m : = f in d ( m e m b e r s h i p I D ) : M e m b e r s h ip

: R e n t a lT r a n s a c t io n

2 .1 : c re a te ( )

: V id e o R e n t a l : V id e o R e n t a l

: M e m b e r s h ip

6. Using the recordVideoRental operation contract as a starting hint, complete the UML collaboration diagram. Annotate every message with the GRASP (Expert, Creator, and so on) and/or other pattern that justifies it.

b y C o n t r o ll e r

b y E x p e rt r e t u r n s " n u l l" i f n o t p r e s e n t

r e c o r d V i d e o R e n t a l( v id e o I D )

: R e n t V id e o s H a n d le r

1 : v : = g e t V id e o ( v id e o I D ) : V i d e o

: C a ta lo g

2 : [ v a li d I D ] a d d V i d e o R e n t a l ( v ) b y C re a to r

1 . 1 v : = f in d ( v id e o I D ) : V i d e o

: R e n t a l T r a n s a c t io n

2 .2 : a d d ( v r )

: V id e o

2 .1 : c r e a te ( v ) : V id e o R e n t a l : V id e o R e n t a l

v r : V id e o R e n t a l

Standard Solution: Design Class Diagrams


7. Draw a partial design class diagram, only for the VideoStore and Membership classes. Show all simple attributes, design-phase associations (with navigability) between these two classes only, and method signatures.

V id e o S t o r e

g e t M e m b e r s h i p ( m e m b e r s h ip I D ) : M e m b e r s h i p 1 O f f e r s -r e n t a ls - t o

*
M e m b e r s h ip m e m b e r s h ip I D : S t r in g s ta r tD a te : D a te

Standard Solution: Mapping Designs to Code


8. Based only on the provided design class diagrams and collaboration diagrams, show the class definition for class VideoStore. Show all instance variable (data member) definitions, but only show the complete method (member function) body definition for one method: getMembership(). Ignore fine details of syntaxthe objective is to evaluate your basic ability to map from designs to code. Use the object-oriented programming language indicated by the examination coordinator.
// Java public class VideoStore { private Hashtable memberships = new Hashtable(); public Membership getMembership( String id ) { return memberships.get( id ); } } // end of class

10

Evaluation: Motivation

Optional Bonus Question


9. (10 marks)
a.

(6 marks) In the approach to analysis and design that has been studied in this course, briefly compare and contrast these two terms. What is analysis about? What is design about?
Analysisinvestigation in order to understand the problem, vocabulary, business rules, and so on. Designa logical (pre-software) solution that fulfills the requirements.

b.

(4 marks) Briefly, what are some motivations for creating 1) conceptual models, and 2) operation contracts?
Conceptual Modelunderstand the vocabulary and the relationship between important concepts. Decompose the problem space in terms of things. Operation ContractsDefine the responsibilities of a system operation. Define the business rules, constraints, and results associated with an operation. Capture in one document much of the relevant detail required to fulfill, in design, the operation.

11

Vous aimerez peut-être aussi