Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is...
-
date post
19-Dec-2015 -
Category
Documents
-
view
218 -
download
1
Transcript of Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is...
![Page 1: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/1.jpg)
Chapter 16
![Page 2: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/2.jpg)
Fig. 16.1
java.awt::Fontor
java.awt.Font
plain : Int = 0 { readOnly }bold : Int = 1 { readOnly }name : Stringstyle : Int = 0...
getFont(name : String) : FontgetName() : String...
«interface»Runnable
run()
- ellipsis “…” means there may be elements, but not shown- a blank compartment officially means “unknown” but as a convention will be used to mean “no members”
SubclassFoo
...
run()...
SuperclassFooor
SuperClassFoo { abstract }
- classOrStaticAttribute : Int+ publicAttribute : String- privateAttributeassumedPrivateAttributeisInitializedAttribute : Bool = trueaCollection : VeggieBurger [ * ]attributeMayLegallyBeNull : String [0..1] finalConstantAttribute : Int = 5 { readOnly }/derivedAttribute
+ classOrStaticMethod()+ publicMethod()assumedPublicMethod()- privateMethod()# protectedMethod()~ packageVisibleMethod()«constructor» SuperclassFoo( Long )methodWithParms(parm1 : String, parm2 : Float)methodReturnsSomething() : VeggieBurgermethodThrowsException() {exception IOException}abstractMethod()abstractMethod2() { abstract } // alternatefinalMethod() { leaf } // no override in subclasssynchronizedMethod() { guarded }
3 common compartments
1. classifier name
2. attributes
3. operations
interface implementation andsubclassing
Fruit
...
...
PurchaseOrder
...
...
1
association with multiplicities
dependency
officially in UML, the top format is used to distinguish the package name from the class name
unofficially, the second alternative is common
order
an interface shown with a keyword
![Page 3: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/3.jpg)
Fig. 16.2
Register
...
endSale()enterItem(...)makePayment(...)
Sale
timeisComplete : Boolean/total
makeLineItem(...)
Register
...
Sale
timeisComplete : Boolean/total
Captures
1
11Domain Model
conceptual perspective
Design Model
DCD; software perspective
currentSale
Note: If Sale references nothing then the only thing it is associatedwith is what references it
Note: association name is missingsince role name of Sale is used asinstance variable name in Register
Note: Why no arrow?
![Page 4: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/4.jpg)
Fig. 16.3
Register
...
...
Sale
...
...
1
Register
currentSale : Sale
...
Sale
...
...
using the attribute text notation to indicate Register has a reference to one Sale instance
using the association notation to indicate Register has a reference to one Sale instance
OBSERVE: this style visually emphasizes the connection between these classes
currentSale
Register
currentSale : Sale
...
Sale
...
...
1thorough and unambiguous, but some people dislike the possible redundancy
currentSale
Note: Use attribute textwhen the data type identityis not important, eg primitives.
visible
![Page 5: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/5.jpg)
Fig. 16.4
the association name, common when drawing a domain model, is often excluded (though still legal) when using class diagrams for a software perspective in a DCD
Register
id: Int
...
Sale
time: DateTime
...
1
currentSale
Register
id : Int
Sale
time : DateTime
Captures-current-sale1 1UP Domain Modelconceptual perspective
UP Design ModelDCD
software perspective
![Page 6: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/6.jpg)
Fig. 16.5
Register
id: Int
...
Sale
time: DateTime
...
1applying the guideline to show attributes as attribute text versus as association lines
Store
address: Addressphone: PhoneNumber
...
1
Register has THREE attributes:1. id2. currentSale3. location
currentSale
location
![Page 7: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/7.jpg)
public class Register { private int id; private Sale currentSale; private Store: location; ...}
![Page 8: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/8.jpg)
Fig. 16.6
notice that an association end can optionally also have a property string such as {ordered, List}
Sale
time: DateTime
...
SalesLineItem
...
...
1..*lineItems
{ordered, List}
Sale
time: DateTimelineItems : SalesLineItem [1..*] orlineItems : SalesLineItem [1..*] {ordered}
...
SalesLineItem
...
...
Two ways to show a collection attribute
property string
![Page 9: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/9.jpg)
Fig. 16.7
Register
...
endSale()enterItem(id, qty)makeNewSale()makePayment(cashTendered)
«method»// pseudo-code or a specific language is OKpublic void enterItem( id, qty ){ ProductDescription desc = catalog.getProductDescription(id); sale.makeLineItem(desc, qty);}
return type is alsotypical
Full Syntax: visibility name (param list):return-type {property-string}
property-string: exceptions, abstract, friend, etc.
declarationmethod
![Page 10: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/10.jpg)
Fig. 16.8
«stereotype»Authorship
author: Stringstatus : String
UML extension relationship to a basic UML metamodel term –Element
«authorship»author = “craig”status = “tested”
«metaclass»Element
...
«authorship»Square
...
using the stereotype
a tool will probably allow a popup to fill in the tag values, once an element has been stereotyped with «authorship»
declaring the stereotype
![Page 11: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/11.jpg)
Fig. 16.9 Dependency
SalesLineItem
...
...
ProductDescription
...
...
1..*lineItems
Sale
...
updatePriceFor( ProductDescription )...
the Sale has parameter visibility to a ProductDescription, and thus some kind of dependency
presence ofcoupling
AClass
foo():void
<<method>>public void foo() { mSale.updatePriceFor(pd)}
mSale1
![Page 12: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/12.jpg)
Kinds of Dependency
-- having an attribute of supplier type
-- sending a message to a supplier using an attribute, param, local variable global variable, static method
-- receiving a parameter of a supplier type
-- supplier is a supertype or interface
Use a dependency line when no other structural line exists.
![Page 13: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/13.jpg)
Foo System
runFinalize()doX()
doX() calls System.runFinalize()
![Page 14: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/14.jpg)
Fig. 16.11
«call»Window
a dependency on calling on operations of the operations of a Clock
Clock
getTime()...
«create»A
a dependency that A objects create B objects
B
...
Example: A factory “creates”an object of a separate classbut has no other relationship to the object.
![Page 15: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/15.jpg)
Fig. 16.12
«interface»Timer
getTime()
Clock1
...
getTime()... lollipop notation indicates Clock3 implements
and provides the Timer interface to clients
Timer is a provided interface
Timer
Clock3
...
getTime()...
Window2
Window3
dependency line notation
Window2 has a dependency on the Timer interface when it collaborates with a Clock2 object
socket line notation
Window3 has a dependency on the Timer interface when it collaborates with a Clock3 object
Window1 Timer
socket line notation
Window1 uses the Timer interface
it has a required interface
Clock2
...
getTime()...
Clock1 implements and provides the Timer interface
Timer
![Page 16: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/16.jpg)
Window1 <<interface>>Timer
<<interface>>Timer
Window3 Clock3
either one
![Page 17: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/17.jpg)
Fig. 16.13
Finger0..7
Hand
composition
1
Square40
Board1
SalesLineItem1..*
Sale1
composition means -a part instance (Square) can only be part of one composite (Board) at a time
-the composite has sole responsibility for management of its parts, especially creation and deletion
Note: Author suggests not using general aggregation; only composition.
![Page 18: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/18.jpg)
Fig. 16.14 Constraints
Stack
size : Integer { size >= 0 }
push( element )pop() : Object
three ways to show UML constraints
{ post condition: new size = old size + 1 }
{ post condition: new size = old size – 1 }
constraint: { text between braces}
![Page 19: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/19.jpg)
Fig. 16.15 Qualified Association
ProductCatalog
ProductDescription
itemID Contains
ProductCatalog
ProductDescription
Contains
1..*
multiplicity reduced to 1
(a)
(b)
qualifier
1
11
qualifier is used to select a specific objectfrom a larger set of objects
![Page 20: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/20.jpg)
Fig. 16.16 Association Class
salarystartDate
Employment
EmploysCompany Person**
a person may have employment with several companies
model an association with attributes and operations
![Page 21: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/21.jpg)
Fig. 16.17 Singleton
1ServicesFactory
instance : ServicesFactory
accountingAdapter : IAccountingAdapterinventoryAdapter : IInventoryAdaptertaxCalculatorAdapter : ITaxCalculatorAdapter
getInstance() : ServicesFactory
getAccountingAdapter() : IAccountingAdaptergetInventoryAdapter() : IInventoryAdaptergetTaxCalculatorAdapter() : ITaxCalculatorAdapter...
UML notation: in a class box, an underlined attribute or method indicates a static (class level) member, rather than an instance member
UML notation: this '1' can optionally be used to indicate that only one instance will be created (a singleton)
![Page 22: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/22.jpg)
Fig. 16.18 Template Classes
«interface»List
clear()...
Kparameterized or template interfaces and classes
K is a template parameter
anonymous class with template binding complete
Board
squares : List<K Square> orsquares : List<Square>...
ArrayList<T Square>
clear()...
the attribute type may be expressed in official UML, with the template binding syntax requiring an arrow orin another language, such as Java
ArrayList
elements : T[*]...
clear()...
T
for example, the elements attribute is an array of type T, parameterized and bound before actual use.
there is a chance the UML 2 “arrow” symbol will eventually be replaced with something else e.g., ‘=’
![Page 23: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/23.jpg)
Fig. 16.19 User Defined Compartments
DataAccessObject
id : Int...
doX()...
exceptions thrownDatabaseExceptionIOException
responsibilitiesserialize and write objectsread and deserialize objects...
![Page 24: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/24.jpg)
Fig. 16.20
«interface»Runnable
run()
Clock
...
run()...
active class
An active class is one controlling its own thread
![Page 25: Chapter 16. Fig. 16.1 Fig. 16.2 Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649d395503460f94a13645/html5/thumbnails/25.jpg)
Fig. 16.21
: Register : Sale
makePayment(cashTendered)
makePayment(cashTendered)
Register
...
makePayment(…)...
Sale
...
makePayment(…)...
1
currentSale
messages in interaction diagrams indicate operations in the class diagrams classes
identified in the interaction diagrams are declared in the class diagrams
in Agile, these diagrams a re drawn in parallel