Upload
evelyn-shaw
View
213
Download
0
Embed Size (px)
Citation preview
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
UML and OOADUML and OOAD
Unified Modeling Language
Object Oriented Analysis and Design
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
UML OriginsUML Origins
A product of the “design wars” of the 1980’sGrady Booch, James Rumbaugh, and others had competing styles.
`94: Rumbaugh leaves GE to join Booch at Rational Software“Method wars over. We won.” Others feared achieving
standardization the Microsoft way.
’95: Rational releases UML 0.8; Ivars Jacobson (use cases) joins Rational“The Three Amigos”
’96: Object Management Group sets up task force on methods’97: Rational proposed UML 1.0 to OMG. After arm
twisting and merging, UML 1.1 emerges’99: After several years of revisions and drafts, UML 1.3 is
released
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
What UML isWhat UML is
• A way to express a software design, mostly through graphical tools
• Is important for communication, does not specify the process used to reach a design. That process is far more more nebulous
• Compare it to using circuit schematics and timing diagrams for documenting hardware designs
• Capture the important details, “the art is knowing what to leave out.”
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
What UML Can Do for UsWhat UML Can Do for Us
• Lets us make out mistakes on paper, before we write and debug the code
• Lets us communicate our ideas better
• Lets us tap into a wealth of existing designs (patterns) that lets us draw on others’ experience
• Lets us use existing tools designed around UMLRational Rose
Rhapsody
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
UML Tools: Class DiagramUML Tools: Class Diagram
•Captures the packaging of the solution into software objects.
•Elaborates the relationships betweeen objects, allowing dependencies to be controlled.
•In an OO language, leads directly to coded objects.
•A good basis for discussion and documentation.
•But, it only shows the static structure.
•Like a circuit diagram in electronics, it shows connectivity but not the dynamics of signals or messages.
Order
dateReceivedisPrepaidnum ber : S tringprince : Money
dispatch()close()
Custom er
nam eaddress
creditRating():S tring
* 1
PersonalCustom er
creditCard#
CorporateCustom er
contactNam ecreditRatingcreditLim it
rem ind()billForMonth(Integer)
Order Line
quantity : Integerprice : MoneyisSatisfied : Boolean
Em ployee
*
0..1
Product* 1
*
1
{creditRating()=="poor"}
sales rep
lineitem s
Multiplic ity: m andatory
Association
RoleNam e
Attributes
Operations
Generalization(inheritance)
Class
Multiplic ity: optional
Multiplic ity: m any-valued
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
UML Tools: Sequence DiagramUML Tools: Sequence Diagram
• Time runs downward
• Shows how objects interact
• Gives the sequence of interactions, but not the precise timing
• Roughly analogous to timing diagrams in electronics
• Have already been extremely useful in developing the DSP communication with the ROD hardware
an O rder Entryw indow
an O rder an O rder L ine a S tock Item
a R eorderItem
a D eliveryItem
prepare ()
* p repare ()
hasS tock :=check()
hasS tock :=rem ove() needsR eorde r:=
needsToR eorde r()
[needsR eorde r]new
[hasS tock ] new
O bject
M essage
IterationC ondition
Self-C all
R eturn
C reation
D eletion
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
UML Tools: State DiagramUML Tools: State Diagram
• Not much different from usage in many other areas
• Describes an object that changes state under specified transition activities and does specified activities in that state
• Another tool for describing dynamic behavior
Checking
do/checkitem
Dispatching
do/in itia tede livery
W aiting Delivered
[N ot a ll item s checked]/get next item
/get firs t item
[A ll item s checked &&all item s availab le ]
D elivered
Item R eceived[som e item s not in s tock ]
start
sta tese lf-transition
transition
activity
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
OOADOOAD
• Going to Object Oriented software is not just changing the syntax of the language. It is a new way of organizing software.
• An object is an instantiation of a class. Just as i can be an instantiation of type integer, x an instantiation of type float and “A” and instantiation of type char, an object myObj can be an instantiation of a (user-defined) class myClass.
• An object has a state (specified by values of attributes) and behavior (given by functions, or methods).
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
OOAD (2)OOAD (2)
• The idea is to keep as many of the details of the objects functionality inside the object and present only a well-defined interface to the outside world.
• Open to extending the behavior or the object, but closed to exposing changes inside the object to the outside world.
• Try to keep one piece of software from depending on changes to another piece.
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
Example 1: VME CrateExample 1: VME Crate
A VME crate has three modules in it: ADC, TDC, CPU.We need a routine that initializes the entire crate.
The old way:
Void initCrate(int crateNumber){ initADC(); initTDC(); initCPU();}
There are smarter ways (e.g. case statements), but there is no way to avoid the need for initCrate to call separate init routines for each type of module.
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
VME Crate (2)VME Crate (2)The OO way:
Void initCrate(crateNumber){// interate over modulesModule.init();}
The routine initCrate no longer needs to know what kind of module it is talking to. We could even add a new type of module and it wouldn’t care.
vmeModule
init()
adcModule
init()
tdcModule
init()
cpuModule
init()
vmeCrate
initCrate()
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
VME Crate (3)VME Crate (3)
• The module-specific details are encapsulated inside the object.
• The various init routines are polymorphic as seen from the outside world.
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
Example 2: Database AccessExample 2: Database Access
myDatabase
addRecord()
simpleTextDb
addRecord()
bigFancyOoDb
dbUser
storeInfo()
addRecord()
As long as the methods of dbUser refer to the interfaces of myDataBase, they will not care whether we use a simple ASCII text file or a messy object oriented database. We can go from one to the other without changing dbUser.
Tom Meyer, Iowa [email protected]
SCT/Pixel Online Workshop18-19 June, 2001
ReferencesReferences
ISBN: 020165783X ISBN: 0132038374