Week 7 (October 14)

Download Report

Transcript Week 7 (October 14)

CSC 520 – Advanced Object
Oriented Programming, Fall, 2010
Thursday, October 14
Week 7, UML Diagrams
http://edn.embarcadero.com/article/31863
UML Class diagrams
Generic
<<interface>>, <<abstract>>, <<active>> other stereotype
Class_or_Interface_Name
- privateAttribute1 : p1Type = initialValue
# protectedAttribute2 : p2Type
~ packageAttribute3 : p3Type
+ publicAttribute4 : p4Type
+ publicStaticAttribute5 : p5Type
- privateOperation1(param1 : T1, …) : m1Type
# protectedOperation2(param1 : T1, …) : m2Type
~ packageOperation3(param1 : T1, …) : m3Type
+ publicOperation4 (param1 : T1, …) : m4Type
+ publicStaticOperation5(param1 : T1, …) : m5Type
+ publicAbstractOperation(param1 : T1, …) : m6Type {abstract}
Generalization, Association, Dependency,
Multiplicity, Keywords
Sequence Diagram shows
sequence of method calls
ScrabbleGame
ScrabbleBoard
ScrabblePlayer
ScrabbleScoreSheet
move
put
validateWord
validateLetters
putWord
deleteTiles
addScore
addTiles
addEntry
Other Sequence Diagram Options
• Filled arrow is the synchronous (waiting) call
• Open arrow is asynchronous (nonblocking)
UML 1.4
UML 1.3
• Create message starts an object’s lifeline.
• Delete message ends an objects lifeline.
• I recommend avoiding conditional control
logic and loops in sequence diagrams.
Activity Diagram
• It is like an old-fashioned flowchart.
•
•
•
•
•
Start
End
Fork and Join (thick horizontal line)
Action, including subdiagrams
Vertical or gridded Partitions can be used to divide
control across objects or deployed components
• Again, avoid using every diagramming option.
Diagrams similar to Class Diagrams
• Package Diagram shows package dependencies.
• Object Diagram shows instantiated objects.
• Useful for showing example run-time relationships.
• Give the name of a class object and assign values to
attributes.
• Component Diagram shows software components
packaged together.
• Dynamic link libraries (DLLs), Java Archives (JARs),
Server Processes, Frameworks, Plugins, etc.
• Multiple class objects and data stores per component.
• Related to deployment diagrams.
Deployment Diagrams
• A 3D box is a Node.
• A Device is hardware.
• An Execution Environment is software (process, OS, …).
• A Node contains Artifacts.
• Executable files, server processes, plugins, DLLs, JARs,
browsers, data files, databases, scripts, etc.
• I prefer to model Artifacts as Components contained
within Nodes.
• Labeled Communication Paths connect Nodes.
Use Case Diagrams
• Stick Figure Actors with interaction ellipses.
• Meyer says OK for validation, not for analysis.
• I find Use Case Text more useful.
• Write simple narratives.
• Identify potential Objects, perhaps drawing
exemplary Object Diagrams.
• Nouns, interactions, class-responsibility-collaboration.
• Capabilities are Meyer’s Deferred Classes (e.g.,
comparable, cloneable, serializable).
• Abstract the Objects into Classes.
State Diagrams = State Machines
• States mirror collection of mutable state variables.
• Initial and final pseudostates for entry and exit.
• Superstate can be modeled as a substate diagram.
• Targeted modeling tools can generate code.
• Transitions between states include triggers (events),
guards (booleans) and activities (outputs).
• Any of these on a given transition is optional.
kayaking flatwater / paddle
current / steer
paddling
drifting
c/s
dest / stop
f/p
dest / stop
State Machine Diagrams continued
• State Diagrams can capture nested, hierarchical
behavior.
• State Diagrams can capture concurrency.
• Specify state variables as part of machine.
• Relate these to attributes in Class Diagrams. Use notes.
• Internal activities list their triggers, guards and
actions. They are like self-transitions.
• Triggers and actions are the I/O of states.
• Guards are conditional entry booleans.
• Add a stack to support a pushdown automaton (not part of UML).
Deployment
• Bundle executable files, data sets, scripts, online help etc. into a distributable format.
• JAR file + manifest = stand alone executable.
• JAR file + HTML + browser = applet.
• Frameworks support run-time configuration
using plugins (games2010rev5, Eclipse).
• Servers and clients support run-time
configuration using plugins, networked
distribution, live update, multithreading.
Multitiered Enterprise Architectures
• Beyond the scope of this course
• Specific systems tend to constrain your perspective.
• http://download.oracle.com/javaee/
• Ajax Web Application Model
Web Server
Web Browser
Data
HTML,CSS,XML data
Ajax
engine
UI
Data
DB
Javascript call
HTTP request
Query / data request