Using UML Patterns and Java ObjectOriented Software Engineering

Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML: UML 2 Hightlights

Outline for today • UML 2: UML is a living language • Overview of important changes in UML 2 • • • Frames and nesting of Frames Activity diagrams Deployment diagrams Sequence diagrams Stereotypes Bernd Bruegge & Allen H. Dutoit 2 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Recent History of UML March 2003: • UML 1. 5 Bernd Bruegge & Allen H. Dutoit 3 July 2005: • UML 2. 0 November 2007: February 2009 • UML 2. 1. 2 • UML 2. 2 Object-Oriented Software Engineering: Using UML, Patterns, and Java

• UML now usable with Model Driven Architecture (MDA) • Better support for the automatic transformation of a Platform Independent Model (PIM) into a Platform Specific Model (PSM) • UML 2 is based on a meta model • Meta Object Facility (MOF) Bernd Bruegge & Allen H. Dutoit 4 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Changes in UML 2 • Frames and nesting • Changes in diagram notations • Activity diagram • Deployment diagram • Sequence diagram • New diagram types (Not covered in this lecture) • Composite structure diagrams • Timing diagrams Bernd Bruegge & Allen H. Dutoit 5 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Frames: Notation for all UML 2 Diagrams • Mandatory is now the contents area • Optional: The contents area can be surrounded with frame and a heading Frame <heading> : : = [<diagram kind>]<name>[<parameters>] Bernd Bruegge & Allen H. Dutoit 6 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Diagram Kinds Diagram Notation Activity diagram Class diagram Component diagram Interaction diagram Package state machine diagram Use case diagram Bernd Bruegge & Allen H. Dutoit 7 The following abbreviations are usually used for diagram frames: act (for activity frames) cmp (for component frames) sd (for interaction frames) pkg (for package frames) stm (for state machine frames) uc (for use case frames) Object-Oriented Software Engineering: Using UML, Patterns, and Java

Nested Diagrams • UML 2 supports nested diagrams • e. g. an activity diagram can be inside a class • The frame concept visually groups elements that belong to one diagram Bernd Bruegge & Allen H. Dutoit 8 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Example of a Activity Diagram with a Frame Bernd Bruegge & Allen H. Dutoit 9 Object-Oriented Software Engineering: Using UML, Patterns, and Java

The Activity Diagram without Frame Bernd Bruegge & Allen H. Dutoit 10 Object-Oriented Software Engineering: Using UML, Patterns, and Java

UML Activity Diagrams An activity diagram consists of nodes and edges • There are three types of activity nodes • Control nodes • Executable nodes • Most prominent: Action • Object nodes • E. g. a document • An edge is a directed connection between nodes • There are two types of edges • Control flow edges • Object flow edges Bernd Bruegge & Allen H. Dutoit 11 Object-Oriented Software Engineering: Using UML, Patterns, and Java

UML Activity Diagrams An activity diagram consists of nodes and edges • There are three types of activity nodes • Control nodes (special icon) • Executable nodes (an oval) • Most prominent: Action • Object nodes • E. g. a document (a rectangle) • An edge is a directed connection between nodes • There are two types of edges • Control flow edges • Object flow edges Bernd Bruegge & Allen H. Dutoit 12 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Control Node Icons in an Activity Diagram • Initial node • Final node • Activity final node • Flow final node • • Fork node Join node Merge node Decision node Bernd Bruegge & Allen H. Dutoit 13 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Activity Diagram Example Decision node Fork node Join node Initial node Merge node Final node Bernd Bruegge & Allen H. Dutoit 14 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Activity Diagram: Activity Nodes & Edges • An activity diagram consists of nodes and edges • There are three types of activity nodes üControl nodes • Executable nodes • Most prominent: Action • Object nodes • E. g. a document • An edge is a directed connection between nodes • There are two types of edges • Control flow edges • Object flow edges Bernd Bruegge & Allen H. Dutoit 15 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Action Nodes and Object Nodes • Object Node Object Name • Action Name Write Thesis Bernd Bruegge & Allen H. Dutoit 16 Thesis Review Thesis Object-Oriented Software Engineering: Using UML, Patterns, and Java

Activity Diagram Example Object node Bernd Bruegge & Allen H. Dutoit 17 Action Object-Oriented Software Engineering: Using UML, Patterns, and Java

Activity Diagram: Activity Nodes & Edges • An activity diagram consists of nodes and edges • There are three types of activity nodes üControl nodes üExecutable nodes • Most prominent: Action üObject nodes • E. g. a document • An edge is a directed connection between nodes • There are two types of edges • Control flow edges • Object flow edges Bernd Bruegge & Allen H. Dutoit 18 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Activity Diagram Example Control flow edge Object flow edge Bernd Bruegge & Allen H. Dutoit 19 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Summary: Activity Diagram Example Decision node Fork node Join node Initial node Merge node Control flow edge Final node Object node Bernd Bruegge & Allen H. Dutoit 20 Action Object flow edge Object-Oriented Software Engineering: Using UML, Patterns, and Java

Activity Diagram: Pins Write Thesis Review Thesis Pin: Alternative notation for an object node • Different notations with same semantics Write Thesis Review Thesis • Both notations define object flow in an activity. Bernd Bruegge & Allen H. Dutoit 21 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Outline for today ü UML 2: UML is a living language ü Overview of important changes in UML 2 ü Frames and nesting ü Activity diagrams Ø Deployment diagrams • Sequence diagrams • Stereotypes Bernd Bruegge & Allen H. Dutoit 22 Object-Oriented Software Engineering: Using UML, Patterns, and Java

UML 2 Deployment Diagrams • Two node types: • Device • Execution environment Bernd Bruegge & Allen H. Dutoit 23 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Deployment Diagram Changes II • Artifacts can now manifest any packageable element, not just components • Manifestation is shown by a dependency with keyword «manifest» Bernd Bruegge & Allen H. Dutoit 24 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Deployment Diagram Changes III • A deployment diagram can have a deployment specification Bernd Bruegge & Allen H. Dutoit 25 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Diagram Kinds ü Activity diagram Class diagram Component diagram Interaction diagram Package state machine diagram Use case diagram Bernd Bruegge & Allen H. Dutoit 26 The following abbreviations are usually used for diagram frames: act (for activity frames) cmp (for component frames) sd (for interaction frames) pkg (for package frames) stm (for state machine frames) uc (for use case frames) Object-Oriented Software Engineering: Using UML, Patterns, and Java

Interaction Diagrams • New concept of interaction fragments • Before we go into detail with interaction fragments, let’s cover the concept of an interaction. Bernd Bruegge & Allen H. Dutoit 27 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Interaction Diagrams • Four types of interaction diagrams: • • Sequence diagrams Communication diagrams Interaction overview diagrams Timing diagrams • The basic building block of an interaction diagram is the interaction • An interaction is a unit of behavior that focuses on the observable exchange of information between connectable elements Bernd Bruegge & Allen H. Dutoit 28 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Interactions • UML Interactions are primarily used during analysis to get a better understanding of the interactions between entity objects • Interactions are also used during the detailed design activity (object design), especially if precise interprocess communication must be set up according to formal protocols • Interactions can finally be used during testing to describe the desired behavior of a system to compare it with the observed behavior. Bernd Bruegge & Allen H. Dutoit 29 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Example of an Interaction: Sequence Diagram Bernd Bruegge & Allen H. Dutoit 30 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Interaction Fragment • Is a piece of an interaction • Acts like an interaction itself • Combined Fragment • Is a subtype of interaction fragment • defines an expression of interaction fragments • An expression of interaction fragments is defined by • an interaction operator and interaction operands. Bernd Bruegge & Allen H. Dutoit 32 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Interaction Operators • A combined fragment defines an expression of interaction fragments. The following operators are allowed in a combined fragment expression: • • • alt opt par loop critical neg assert strict seq Ignore consider Bernd Bruegge & Allen H. Dutoit 33 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Alt Operator • The interaction operator alt indicates a choice of behavior between interaction fragments • At most one interaction fragment (that is, an Interaction. Operand) is chosen • The chosen interaction fragment must have an explicit or implicit guard expression that evaluates to true at this point in the interaction • A guard can be • a boolean expression (called Interaction. Constraint) • else (a reserved word) • If the fragment has no guard expression, true is implied. Bernd Bruegge & Allen H. Dutoit 34 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Example of a Combined Fragment using alt Bernd Bruegge & Allen H. Dutoit 35 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Opt and Break Operators option: The interaction operator opt designates a choice of behavior where either the (sole) operand happens or nothing happens. break: The interaction operator break represents a breaking scenario: The operand is a scenario that is performed instead of the remainder of the enclosing interaction fragment. Bernd Bruegge & Allen H. Dutoit 36 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Parallel and Critical Operator par The interaction operator par designates a parallel merge between the behaviors of the operands of a combined fragment. critical The interaction operator critical designates that the combined fragment represents a critical region. Bernd Bruegge & Allen H. Dutoit 37 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Example of a Critical Region Problem statement: The telephone Operator must make sure to forward a 911 -call from a Caller to the Emergency system before doing anything else. Normal calls can be freely interleaved.

One more thing: Modeling Real-Time Constraints • The duration of a message and the duration between two event occurrences can be constrained with a time constraint. Bernd Bruegge & Allen H. Dutoit 39 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Where are we? ü Introduction ü Frames and nesting ü Changes in diagram notation: ü Activity diagram ü Deployment diagram ü Sequence diagram Ø Profiles and stereotypes Bernd Bruegge & Allen H. Dutoit 40 Object-Oriented Software Engineering: Using UML, Patterns, and Java

More on meta classes and meta modeling in the next lecture (today or on Friday) Stereotype • Defines how an existing meta class may be extended • A meta class may be extended by one or more stereotypes • Why do we want to do this? • Example: • Insertion of solution domain abstractions in the model (such as platform specific classes) • Sterotypes allow a clear separation from the application domain abstractions. Bernd Bruegge & Allen H. Dutoit 41 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Stereotype Notations • A stereotype is a string enclosed in guillemets before the classifier name • E. g. «Clock» Stop. Watch, «boundary» button • Stereotypes can also be represented with a graphical icon • The icon can even replace the standard notation (icons for a class, object, use case, etc). Bernd Bruegge & Allen H. Dutoit 42 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Icons and Symbols for Stereotypes • One can use icons or graphical symbols for stereotypes • When the stereotype is applied to a UML model element, the graphic replaces the standard notation for the model element • Example: Modeling a network, use icons for representing classes of type Switch, Server, Router, Printer Icon for Router class Icon for Switch class Bernd Bruegge & Allen H. Dutoit 43 Icon for Server Class Object-Oriented Software Engineering: Using UML, Patterns, and Java

Pros and Cons of Stereotype Graphics • Advantages: • UML diagrams may be easier to understand if they contain graphics and icons for stereotypes • This can increase the readability of the diagram, especially if the client is not trained in UML • And they are still UML diagrams! • Disadvantages: • If developers are unfamiliar with the symbols being used, it can become much harder to understand what is going on • Especially in high level management presentations • Additional symbols add to the burden of learning to read the diagrams • If you end up applying stereotypes all over your model, you should think of defining a profile (see next lecture). Bernd Bruegge & Allen H. Dutoit 44 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Stereotypes vs. Keywords • Not to be mixed up with keywords • Same notation (String enclosed in guillemets) • «interface» is no stereotype! • «extend» is no stereotype! • See Annexes B and C of the UML Superstructure specification. Bernd Bruegge & Allen H. Dutoit 45 Object-Oriented Software Engineering: Using UML, Patterns, and Java

Additional Readings • UML 2. 2 specification • The specification consists of two complementary parts which constitute the complete speciication of UML 2: • Infrastructure and Superstructure. • The infrastructure specification defines the foundational language constructs • http: //www. omg. org/spec/UML/2. 2/Infrastructure/PDF • The superstructure defines the user level constructs. • http: //www. omg. org/spec/UML/2. 2/Superstructure/PDF • For a complete list of all UML specifications, see • http: //www. omg. org/spec/UML/ Bernd Bruegge & Allen H. Dutoit 46 Object-Oriented Software Engineering: Using UML, Patterns, and Java
- Slides: 45