150 likes | 254 Views
Analysis 2: Realizing Use Cases [A&N 12]. Recall, use case (your requirement). Online shop system. credit card company. Pay. customer. ID 1: Buy Desc : a customers pay the items she has in the basket. Primary actors : customer Secondary actors: credit card company
E N D
Recall, use case (your requirement) Online shop system credit card company Pay customer ID 1: Buy Desc: a customers pay the items she has in the basket. Primary actors: customer Secondary actors: credit card company Pre-conditions: basket is not empty Main flow: The use-case starts when the customer requests it. The system determines the total price of the items in the basket. The system charges the price to the customer’s credit card. Post-conditions: the basket is empty
Use case “realization” • Elements of this realization • Analysis class diagrams • Refined use case • Interaction models sequence diagrams • Special requirements (that cannot be expressed with diagrams ) • “modeling interactions” : • top level “system sequence diagram” • between your analysis classes, towards realizing a given use case
Visually modeling use case flow with sequence diagram sd Buy : credit card company : System : customer buy () p = getTotalPrice() charge(p) • context • lifeline • activation region • The above is called “system SD”
Analysis classes Suppose we come up with these analysis classes : owns consists of Customer Basket Item * 1 CreditCard 1 • determine total price • charge customer What are the responsibilities ?
Analysis level sequence diagram owns consists of Customer charge(amount) Basket getTotalPrice() Item * 1 CreditCard sd Buy : credit card company b : Basket c : Customer : System : customer buy() getTotalPrice() totprice charge(totprice) charge(totprice) An SD models interactions between instances of some classes. also a limitation... Still, you can express a lot.
Realizing alternate flows Supposed the main flow of “Pay” use case is conditioned by a “valid” card; and else we have an alternate flow that simply doesn’t charge ... : credit card company : System b : Basket c: Customer u : CreditCard buy() getTotalPrice() totprice validate() validate() vld opt [vld=true] charge(totprice) charge(totprice) charge(totprice) reset()
Other constructs a ref • So you can modularly structure your diagram • And you can leave holes to be refined later • See also ch. 13 Name.. b alt loop [condition] [condition-1 ] a a1 b b [condition-2] a2
Lifeline constraint, state invariant b : Basket c : Customer : System buy() A getTotalPrice() getPrice() totprice { totprice > 0 } charge(totprice) reset() B empty { B – A < 3 min}
Other constructs maybe more relevant for “Design” ... par a1 b a2 co-region [ ] c u critical v More constructs, see A&N
Suppose in design we refine to: owns consists of Basket getTotalPrice() Item getPrice() Customer charge(amount) * 1 CreditCard validate() charge(amount) b : Basket : System getTotalPrice() for all item i in the basket : UML does give you a loop construct; but it can’t really express an iteration like this. As a side note, in this case it is a point of discussion whether you should put the iteration in a model of this level. i : Item getPrice() { p = total price } p
Example : online auction • What are the actors ? • Use cases ? • Your analysis classes ? • User can bid on an auctioned item, until item’s deadline • 3 minutes “open” window, then 2 minutes “blocked” • User can buy-out the item
Item minPrice buyOutPrice bid(p,user) buyout(user) highest bidder User charge(amount) 0..1 sd Bid :Item : System u: User alt [ item is blocking || deadline passed || soldout] bid(p) refuse [else] bid(p) critical bid(u,p) result result
sd Buy out u:User i:Item : System u: User alt [ item is blocking || deadline passed || soldout] buyout() refuse [else] buyout() buyout(u) charge(i.buyoutPrice) ok
Timing diagram t = 3min open : Item this basically is a time line blocking t <= 2 min bid(p) rejected : User