You are on page 1of 14

UML and OOAD

Unified Modeling Language Object Oriented Analysis and Design

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

UML Origins
A product of the design wars of the 1980s
Grady 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 RationalThe 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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

What 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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

What 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 UML
Rational Rose Rhapsody

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

UML 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.
line items Role Name Multiplicity: mandatory

Order Customer
dateReceived isPrepaid number : String prince : Money dispatch() close() name address creditRating():String

*
Association Generalization (inheritance)

Class

Attributes

Corporate Customer
contactName creditRating creditLimit remind() billForMonth(Integer)

Personal Customer
creditCard# {creditRating()== "poor"}

Operations

*
sales rep

Multiplicity: many-valued

* Order Line

0..1

Multiplicity: optional

Employee
quantity : Integer price : Money isSatisfied : Boolean

Product

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

UML 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 Order Entry window
prepare()

an Order

an Order Line

a Stock Item

Object
* prepare() hasStock:= check()

Message Iteration

Condition
hasStock:= remove() needsReorder:= needsToReorder()

Self-Call

Return

[needsReorder] new

a Reorder Item

[hasStock] new

a Delivery Item

Creation

Deletion

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

UML 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
start
/get first item

[Not all items checked] /get next item

Checking do/check item

[All items checked && all items available]

Dispatching do/initiate delivery

It [a em ll it e R e m ce s iv av ed ai la bl e]

activity
Delivered

transition

Item Received [some items not in stock]

Waiting

Delivered

self-transition

state

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

OOAD
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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

OOAD (2)
The idea is to keep as many of the details of the objects functionality inside the object and present only a welldefined 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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

Example 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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

VME Crate (2)


The OO way:
vmeModule
init() vmeCrate initCrate()

adcModule init()

tdcModule init()

cpuModule init()

Void initCrate(crateNumber) { // interate over modules Module.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 wouldnt care.

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

Example 2: Database Access


myDatabase
addRecord() dbUser storeInfo()

simpleTextDb addRecord()

bigFancyOoDb 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 State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

References

ISBN: 020165783X

ISBN: 0132038374

Tom Meyer, Iowa State Meyer@iastate.edu

SCT/Pixel Online Workshop


18-19 June, 2001

You might also like