Requirements To Design--Iteratively Chapter 12 Applying UML and Patterns Craig Larman.
1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.
-
Upload
ruby-harvey -
Category
Documents
-
view
224 -
download
5
Transcript of 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.
![Page 1: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/1.jpg)
1
On To Object Design
Chapter 14
Applying UML and Patterns
-Craig Larman
![Page 2: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/2.jpg)
2
Connection between SSDs, System Operations and Layers
In a well-designed layered architecture that supports high cohesion and a separation of concerns, the UI layer objects will then forward the request from the UI layer onto the domain layer for handling.
![Page 3: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/3.jpg)
How design objects?
Code : Design while coding
Draw , then code : UML on a
whiteboard , then switch to code
Only draw: tools generate
everything from diagrams.
3
![Page 4: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/4.jpg)
WSEP 06
Designing ObjectsStatic and dynamic modeling.
Two kinds of object models:
• Static models :• Class diagrams / Package diagram / Deployment diagram
Helps design definition of packages, class name, attributtes and method signature
• Dynamic models:• Interaction Diagrams/ (Sequence / comunication). State machine
diagrams/activity diagram
Illustrate how objects collaborate via messages and methdos . They help design the logic and method bodies
![Page 5: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/5.jpg)
5
Agile modeling practice Create Models in parallel! ( interaction diagram and class diagram)Modeling with others
![Page 6: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/6.jpg)
6
UML INTERACTION DIAGRAMS
Chapter 15
Applying UML and Patterns
-Craig Larman
![Page 7: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/7.jpg)
Sequence Diagrams 7
A First Look at interaction Diagrams
Illustrate how objects interacts with each other.
Emphasizes time ordering of messages.
Can model simple sequential flow, branching, iteration (loop) , …etc
Sequence / communication
![Page 8: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/8.jpg)
sequence diagram
: A myB : B
doTwo
doOne
doThree
Each new object is added to the right
Method of Object A
Class A has an attribute of type B to be able to call doTwo and doThree.
Methods of Object B
![Page 9: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/9.jpg)
Code
public class A{ private B myB= new B();
Public void doOne(){ myB.doTwo();myB.doThree();}
}
Class A has an attribute of type B.
Class A has a method named doOne
Class B has methods named doTwo and doThree
![Page 10: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/10.jpg)
Communication diagram
: A
myB : B
1: doTwo
2: doThree
doOne
![Page 11: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/11.jpg)
Interaction Diagram notation
class instance named instance
:Sale s1:SaleSale
![Page 12: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/12.jpg)
sales: ArrayList<Sale>
:Sale s1 : Sale
lifeline box representing an instance of an ArrayList class, parameterized (templatized) to hold Sale objects
lifeline box representing an unnamed instance of class Sale
lifeline box representing a named instance
sales[ i ] : Sale
lifeline box representing one instance of class Sale, selected from the salesArrayList <Sale> collection
x : List
«metaclass»Font
lifeline box representing the class Font, or more precisely, that Font is an instance of class Class – an instance of a metaclass
related example
List is an interface
in UML 1.x we could not use an interface here, but in UML 2, this (or an abstract class) is legal
Common UML Interraction diagram notation
lifeline
![Page 13: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/13.jpg)
Basic Sequence diagram notation
: Register : Sale
doA
doB
doX
doC
doD
typical sychronous message shown with a filled-arrow line
a found message whose sender will not be specified
execution specification bar indicates focus of control
![Page 14: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/14.jpg)
How to illustrate a return result ?
: Register : Sale
d1 = getDate
getDate
doX
aDate
Is equivalent to
![Page 15: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/15.jpg)
Messages sent to itself
: Register
doX
clear
![Page 16: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/16.jpg)
Creation of Instances
: Register : Sale
makePayment(cashTendered)
: Paymentcreate(cashTendered)
authorize
note that newly created objects are placed at their creation "height"
Dashed line
Sale class will invoke the new operator and call the constructor.
![Page 17: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/17.jpg)
Object destruction
: Sale
: Paymentcreate(cashTendered)
...the «destroy» stereotyped message, with the large X and short lifeline indicates explicit object destruction
«destroy» X
![Page 18: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/18.jpg)
Conditional message : OPT frame is placed around one or more messages.
calculate
: Bar
yy
xx
[ color = red ]opt
: Foo
opt: Optional fragment that execute if guard [color=red] is true
![Page 19: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/19.jpg)
Conditional message : UML1.x notation
[ color = red ] calculate
: Bar
yy
xx
: Foo
![Page 20: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/20.jpg)
which notation do you prefer?
calculate
: Bar
yy
xx
[ color = red ]opt
: Foo
[ color = red ] calculate
: Bar
yy
xx
: Foo
![Page 21: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/21.jpg)
Loops (iteration over a collection)
st = getSubtotal
lineItems[i] :SalesLineItem
t = getTotal
[ i < lineItems.size ]loop
: Sale This lifeline box represents one instance from a collection of many SalesLineItem objects.
lineItems[i] is the expression to select one element from the collection of many SalesLineItems; the ‘i” value refers to the same “i” in the guard in the LOOP frame
an action box may contain arbitrary language statements (in this case, incrementing ‘i’)
it is placed over the lifeline to which it applies
i++
![Page 22: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/22.jpg)
Code page 234
22
![Page 23: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/23.jpg)
Loops (iteration over a collection)
st = getSubtotal
lineItems[i] :SalesLineItem
t = getTotal
loop
: Sale
![Page 24: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/24.jpg)
Which notation do you prefer
st = getSubtotal
lineItems[i] :SalesLineItem
t = getTotal
[ i < lineItems.size ]loop
: Sale This lifeline box represents one instance from a collection of many SalesLineItem objects.
lineItems[i] is the expression to select one element from the collection of many SalesLineItems; the ‘i” value refers to the same “i” in the guard in the LOOP frame
an action box may contain arbitrary language statements (in this case, incrementing ‘i’)
it is placed over the lifeline to which it applies
i++
st = getSubtotal
lineItems[i] :SalesLineItem
t = getTotal
loop
: Sale
![Page 25: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/25.jpg)
Nesting of frames
25
![Page 26: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/26.jpg)
How relate Interaction diagram?
26
![Page 27: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/27.jpg)
Invoke static (class)methods
27
![Page 28: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/28.jpg)
Polymorphism in interaction diagrams?
28
![Page 29: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/29.jpg)
UP artifacts influencing OO design
Operation: enterItem(…)
Post-conditions:- . . .
Operation Contracts
Sale
date. . .
SalesLineItem
quantity
1..*1 . . .
. . .
Domain Model
Use-Case Model
Design Model: Register
enterItem(itemID, quantity)
: ProductCatalog
d = getProductDescription(itemID)
addLineItem( d, quantity )
: Sale
Require-ments
Business Modeling
Design
Sample UP Artifact Relationships
: System
enterItem(id, quantity)
Use Case Text
System Sequence Diagrams
makeNewSale()
system events
Cashier
Process Sale
: Cashier
use case
names
system operations
Use Case Diagram
SupplementarySpecification
Glossary
starting events to design for, and detailed post-condition to satisfy
Process Sale
1. Customer arrives ...2. ...3. Cashier enters item identifier.
inspiration for names of some software domain objects
functional requirements that must be realized by the objects
ideas for the post-conditions
Register
...
makeNewSale()enterItem(...)...
ProductCatalog
...
getProductDescription(...)...
1*
non-functional requirements
domain rules
item details, formats, validation
![Page 30: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/30.jpg)
Questions?
30
![Page 31: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/31.jpg)
aMember: BookBorrower
theLibraryMember:LibraryMember
theCopy: Copy theBook: Book
borrow (theCopy)1: okToBorrow
2: borrow2.1:borrowed
Can you guess the scenario from this interaction diagram ?
![Page 32: 1 On To Object Design Chapter 14 Applying UML and Patterns -Craig Larman.](https://reader036.fdocuments.in/reader036/viewer/2022062309/56649f2a5503460f94c44dc0/html5/thumbnails/32.jpg)
Collaboration diagram: Library System
BookBorrower
borrow()
2:borrow()
1:okToBorrow()
2.1: borrowed()
:LibraryMember theCopy:Copy
:Book