130 likes | 140 Views
Discover the intricacies of UML diagrams, including Class, Sequence, Activity, Package, Component, Deployment, Use Case, State Machine diagrams for advanced object-oriented programming. Gain insights into modeling software components, system interactions, and state behaviors.
E N D
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 showssequence of method calls ScrabbleGame ScrabbleBoard ScrabblePlayer ScrabbleScoreSheet move put validateWord validateLetters putWord deleteTiles addScore addEntry addTiles
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 ExecutionEnvironment 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 CommunicationPaths connect Nodes.
Use Case Diagrams • Stick Figure Actors with interaction ellipses. • Meyer says OK for validation, not for analysis. • I find UseCaseText more useful. • Write simple narratives. • Identify potential Objects, perhaps drawing exemplary ObjectDiagrams. • Nouns, interactions, class-responsibility-collaboration. • Capabilities are Meyer’s DeferredClasses (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. dest / stop kayaking flatwater / paddle paddling f / p c / s drifting dest / stop current / steer
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 pushdownautomaton (not part of UML).
Deployment • Bundle executable files, data sets, scripts, on-line 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 Data HTML,CSS,XML data Ajax engine UI DB Javascript call HTTP request Query / data request