Lecture 33 April 4, Unied Modelling Language. ECE155: Engineering Design with Embedded Systems Winter Patrick Lam version 1

Similar documents
Engineering Design w/embedded Systems

Software Service Engineering

Introduction to Software Engineering. 5. Modeling Objects and Classes

Exercise Unit 2: Modeling Paradigms - RT-UML. UML: The Unified Modeling Language. Statecharts. RT-UML in AnyLogic

Introduction to Software Engineering. 5. Modeling Objects and Classes

UML Modeling I. Instructor: Yongjie Zheng September 3, CS 490MT/5555 Software Methods and Tools

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

Object Oriented Modeling

Software Engineering Lab Manual

The Dynamic Model. An Introduction to UML. Enterprise Architect. by Geoffrey Sparks. All material (c) Geoffrey Sparks

UML (Unified Modeling Language)

MSc programme (induction week) Department of Informatics INTRODUCTION TO UML

LABORATORY 1 REVISION

Meltem Özturan

Unified Modeling Language (UML)

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Session 8: UML The Unified Modeling (or the Unstructured Muddling) language?

Lab Manual. Object Oriented Analysis And Design. TE(Computer) VI semester

administrivia today UML start design patterns Tuesday, September 28, 2010

UML Tutorial. Unified Modeling Language UML Tutorial

Course 3 7 March

Object-Oriented Design

Object-Oriented Analysis and Design. Pre-UML Situation. The Unified Modeling Language. Unification Efforts

The Unified Modeling Language (UML)

UML 2.0 UML 2.0. Scott Uk-Jin Lee. Division of Computer Science, College of Computing Hanyang University ERICA Campus

EVALUATION COPY. The Unified Modeling Language. Unauthorized reproduction or distribution is prohibited. Student Workbook

Interactions A link message

Object-Oriented Analysis and Design

Developing Shlaer-Mellor Models Using UML

Unified Modeling Language

EE 446 EMBEDDED ARCHITECTURE Embedded System in UML (2)

2 UML for OOAD. 2.1 What is UML? 2.2 Classes in UML 2.3 Relations in UML 2.4 Static and Dynamic Design with UML. UML for OOAD Stefan Kluth 1

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

UML Sequence Diagrams for Process Views

UNIT-I Introduction of Object Oriented Modeling

UML Diagrams & And Some Of Their Elements

Software Design And Modeling BE 2015 (w. e. f Academic Year )

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

Object-Oriented and Classical Software Engineering

BUILDING BLOCKS. UML & more...

How and Why to Use the Unified Modeling Language. among software components, architectural-based

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Unit-1 INTRODUCTION 1.1 CATEGORIES OF INFORMATION SYSTEMS SYLLABUS:

Introduction to Software Engineering. 6. Modeling Behaviour

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Requirements Gathering using Object- Oriented Models UML Class Diagram. Reference:

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

Unified Modeling Language (UML)

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

UML Primer. -Elango Sundaram

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

UML Component Diagrams A.Y 2018/2019

Software Development. Modular Design and Algorithm Analysis

UML- a Brief Look UML and the Process

1 Introduction. 1.1 Introduction

Object-Oriented Software Engineering Practical Software Development using UML and Java

Lecture #2 on Object-Oriented Modeling

Software Development Methodologies

Computer Science 520/620 Spring 2013 Prof. L. Osterweil" Use Cases" Software Models and Representations" Part 4" More, and Multiple Models"

Computer Science 520/620 Spring 2013 Prof. L. Osterweil" Software Models and Representations" Part 4" More, and Multiple Models" Use Cases"

Software Engineering

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

Chapter 12. UML and Patterns. Copyright 2008 Pearson Addison-Wesley. All rights reserved

SOFTWARE ENGINEERING UML FUNDAMENTALS. Saulius Ragaišis.

Today s Topic. Lecture 5. What is UML? Why Use UML. UML Diagrams. Introduction to UML. What is UML Why use UML? UML Diagrams

An Introduction To Object Modeling System Concept for Object Modeling The Overall View Components of UML Diagram

1 Reference Material for these slides is taken from many UML reference books. However, the two I most often used are: UML Explained, by Kendall Scott,

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

INTRODUCTION TO UNIFIED MODELING MODEL (UML) & DFD. Slides by: Shree Jaswal

CHAPTER 1. Topic: UML Overview. CHAPTER 1: Topic 1. Topic: UML Overview

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

EECE 310: Software Engineering

Chapter 5: Structural Modeling

EECS 4314 Advanced Software Engineering. Topic 03: UML Overview Zhen Ming (Jack) Jiang

From Analysis to Design. LTOOD/OOAD Verified Software Systems

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

Models are used for several purposes. We believe that some of the most important are:

Object Oriented Modeling and Design

Experiment no 4 Study of Class Diagram in Rational Rose

UML-Based Conceptual Modeling of Pattern-Bases

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

LESSON PLAN SUB NAME : OBJECT ORIENTED ANALYSIS AND DESIGN UNIT SYLLABUS

Introducing the UML Eng. Mohammed T. Abo Alroos

UNIT 5 - UML STATE DIAGRAMS AND MODELING

Computer Science 520/620 Spring 2014 Prof. L. Osterweil" Use Cases" Software Models and Representations" Part 4" More, and Multiple Models"

Software Engineering

12 Tutorial on UML. TIMe TIMe Electronic Textbook

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

Oral Questions. Unit-1 Concepts. Oral Question/Assignment/Gate Question with Answer

Unified Modeling Language - UML

CISC 322 Software Architecture

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

Course "Softwaretechnik Modeling with UML Stephan Salinger

Research Review on Basic Principles of Unified Modelling Language

UML part I. UML part I 1/41

SEEM4570 System Design and Implementation Lecture 11 UML

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Transcription:

ECE155: Engineering Design with Embedded Systems Winter 2013 Lecture 33 April 4, 2013 Patrick Lam version 1 Unied Modelling Language The Unied Modelling Language (UML) is a language for specifying and documenting the architecture of large object-oriented software systems, using diagrams. UML version 2.2 includes 13 dierent diagrams, which can summarize a system's intended structure (e.g. classes), behaviour, and interactions of components. Historical Note. UML combines earlier modelling languages, and was initially developed by Grady Booch, James Rumbaugh, and Ivar Jacobson (The Three Amigos) in the 1990s. Version 1.4.2 of UML is an ISO standard, and future versions of UML are controlled by the Object Management Group consortium. Resources. There are a lot of webpages (some inaccurate) with information about UML. Here are some resources: The ocial UML page is at http://www.uml.org; it contains links to the ocial specication, tutorials, and links to tool support. One useful tutorial on practical UML is at http://edn.embarcadero.com/article/31863. It contains sample diagrams, and also broken links. The denitive UML book is: Grady Booch, James Rumbaugh, and Ivar Jacobson. Unied Modeling Language User Guide, 2nd Edition, Addison-Wesley, 2005. Another book is Dan Pilone and Neil Pitman. UML 2.0 in a Nutshell. O'Reilly Media, 2005. Ocial specication: http://www.omg.org/technology/documents/formal/uml.htm. Benets of UML. We are teaching UML because it is a well-known language for talking about software designs. In particular: UML is a visual language, and UML models are diagrams, so they're easy to glance at. UML models are largely self-documenting. UML is agnostic in terms of software processes or development lifecycles. UML is an open standard (not owned by any one company). UML is good for object-oriented languages, which are quite common in industry. 1

Criticisms of UML. Here are a few complaints one might have: UML is all syntax, no meaning. UML contains redundant and infrequently-used constructs. UML is complex and dicult to learn. UML only works for object-oriented languages. UML tools don't play nicely together. UML Diagrams. Let's look at the dierent categories of UML diagrams in UML 2.2: Structure Diagrams represent the static application structure. Examples: class diagrams, object diagrams, component diagrams, composite structure diagrams, package diagrams, deployment diagrams. Behaviour Diagrams encode the usage of components, the activity of components, and nitestate machines summarizing components' states. Examples: use case diagrams, activity diagrams, state machine diagrams. Interaction Diagrams describe how components interact; they may communicate or synchronize with each other, potentially respecting timing constraints. Examples: sequence diagrams, communication diagrams, timing diagrams, and interaction overview diagrams. Tool Support. A number of software tools can create UML diagrams, including Microsoft Visio and dia. Some tools can generate source code from UML diagrams and UML diagrams from source code; if a tool can do both, we say that it round-trips. Tools can also, to some extent, automatically generate test cases and test suites from UML diagrams. UML Class Diagrams The basic UML diagram is the class diagram, which describes the members of a class. You saw this in ECE150, although maybe it wasn't called a class diagram. Members include attributes/elds and operations (constructors, destructors, methods, indexers, and properties). Here's a simple example of a UML diagram. +mydata: string MyClass +MyClass() +myfunction(param:string): string 2

UML Symbols. Note that the above diagram includes a + for public visibility. Here are the possible visibility symbols: A + (plus sign) indicates public visibility. A - (minus sign) indicates private visibility. A # (hash sign) indicates protected visibility. UML also uses the following symbols: A (tilde) indicates a destructor (in front of an operation) or package (as a visibility symbol). An.. (ellipsis) indicates a range of values. A : (colon) separates a name from a type. A, (comma) separates items in a set. More Complicated Example. Here are some more features of UML: c l a s s Employee { protected S t r i n g name ; protected S t r i n g a d d r e s s ; protected i n t age ; protected S t r i n g s o c i a l I n s u r a n c e N u m b e r ; public S t r i n g e m a i l ; private long sortkey ; } public Employee ( S t r i n g pname, S t r i n g paddress, i n t page, S t r i n g psin ) { /... / } @Override public S t r i n g t o S t r i n g ( ) { /... / } public s t a t i c boolean s o r t ( ) { /... / } Class Hierarchies in UML UML includes a number of notations for representing relationships between classes and instances. The following relationships are between instances of classes. 3

An association represents a relationship between instances of two classes. An aggregation is a type of association, typically between a collection or container instance and its contents. A composition is another type of association, typically used between a container and its contents. For a composition, the contents don't make any sense if the container isn't around. On the other hand, a generalization relates base classes (not instances) and their derived classes. Associations. There is an association between two classes if there is a relationship between instances of the classes. This is one of the has-a links between classes. Typically one of the classes can call methods on the other. Instructor 1..* Teaches 0..3 University Course Instructors and courses are associated, but there is no subtype relationship, and the types are not collection types. Instructors teach between 0 and 3 courses per term. Each course has at least 1 instructor, but possibly an unlimited number. A method that the instructor might call on the course might be givelecture(). Aggregations and Compositions. These specialized types of associations also represent has-a relationships, but more part-whole relationships. A Linked List contains 0 or more Elements, but Elements belong to only one Linked List; however, the composition means that we are saying that Elements may not exist independently of a Linked List. Computers contain 1 or more Processors, but Processors only belong to 1 Computer. In a composition, we are stating that Processors can exist independently of a Computer. 4

Generalizations. These relationships are between classes. Salaried Employee Employee Hourly Employee Every Salaried Employee and Hourly Employee is an Employee, so Employees are generalizations of the Salaried and Hourly Employee classes. In the code, you'd see that Salaried Employee and Hourly Employee are subclasses of (extend) Employee. Fancier UML Class Diagrams. Here is a complex UML class diagram from http://www. altova.com/umodel/class-diagrams.html (accessed March 10, 2011). Note the member eld initializations and the generalization link. 5

Here is another class diagram, from http://edn.embarcadero.com/article/31863 (accessed March 10, 2011). UML State Diagrams Goal. You should be able to read a description of a nite state machine (either in code or in text) and produce a syntactically correct UML state diagram summarizing that design. (The UML State Diagram examples are from UML Distilled, Second Edition, by Martin Fowler with Kendall Scott.) We've talked about nite-state machines a few times in ECE155 and your other courses. possible to document these machines in UML using state diagrams. Here's an example. It is 6

States. This state diagram illustrates the states of an order in an order processing system. The order object has four states, represented by boxes, with the name of the state in the upper half of the box: checking, dispatching, waiting, and delivered. The lower half explains what the activity in that state is; for instance, the dispatching state initiates the delivery of the order. In ECE155, you can always put do before the slash and the activity after the slash. In general, a state has a name and may have an activity. Objects carry out activities, and these activities take some amount of time. Transitions. The edges in the graph represent transitions between states. Transitions may optionally be labelled. There are three parts to a transition label, as follows: Event [Guard] / Action. For instance, the self-transition from the checking state contains the guard [not all items checked] and performs the action get next item. An event is something that happens to an object, like Item Received. A guard is a logical condition that states the conditions under which the event may occur (e.g. [some items not in stock]). Objects carry out actions, e.g. get next item; actions must occur quickly and be uninterruptible (contrast this with an activity, which takes longer and gets interrupted by events). An object takes a transition if the event occurs and the guard is true. Before it completes the transition and enters the destination state, it carries out the action. UML state machines should be designed to be deterministic: at most one transition should be activated at once. Superstates. State diagrams may get too complicated to easily understand. UML state diagrams include the notion of hierarchical nesting to help you write clearer diagrams; such diagrams allow you to see the higher-level structure of the system. In particular, UML state diagrams include the notion of a superstate. A superstate may contain 7

nested states and transitions, which make up a state machine for some subset of the entire machine's behaviour. The following example includes an example of a superstate, active, which includes the checking and dispatching states inside it. Note also that there are transitions from individual states inside the superstate, e.g. from dispatching to delivered, as well as a transition from the superstate to the cancelled state. This transition means that either of the states in the superstate can get to cancelled. It is equivalent to drawing transitions from both dispatching and checking to cancelled. Checking do/ check item Active [all items available] Dispatching do/ initiate delivery Cancelled Delivered (From: http://atlas.kennesaw.edu/~dbraun/csis4650/a&d/uml_tutorial/state.htm. Accessed July 3, 2011.) Timing. Timing is important for embedded systems. Your documentation should explain what quickly (as in an action) means; UML doesn't say, and it depends on the system. You can also write an event that happens after some time, e.g. after (20 minutes). UML Use Case Diagrams The next kind of UML diagram we'll talk about is the use case diagram. We'll talk about use cases shortly; a use case describes a user's interaction with the system. In these diagrams, users (or other systems) are known as actors, who play roles in the behaviour of the system. The following gure from the embarcadero site explains: 8

Here is a case with multiple actors: It's just a coincidence that each use case has two actors. Finally, here's another use case diagram, from http://msdn.microsoft.com/en-us/library/dd409427% 28VS.100%29.aspx (accessed March 10, 2011). Again, we have 1) actors, 2) use cases, 3) communication, and, new to this gure, 4) subsystems or components. 9

The following diagram indicates relationships between use cases and actors. Here we have 5) inclusion stereotypes on dependencies; 6) extension stereotypes on dependencies; 7) inheritance relationships between use cases; 8) plain dependencies; 9) comments; and 10) references to other artifacts. A communication (solid line) represents a relationship between an actor and a use case. An inclusion (dashed line, include stereotype) represents an invocation relationship between use cases; the rst use case must call the second one. An extension (dashed line, extend stereotype) represents an optional invocation of a use case. A generalization or specialization represents a case where an actor or use case inherits from another actor or use case. Why use UML Use Case Diagrams? These diagrams can be useful for 1) documenting essential features (requirements) of a software system; 2) communicating system behaviour to clients; 3) generating appropriate test cases for scenarios. UML Sequence Diagrams The last kind of UML diagram we'll talk about is the sequence diagram. UML sequence diagrams express system behaviour as a sequence of events and activities. (Message sequence charts do the same thing.) In a sequence diagram, you'll nd objects, lifelines, messages, action boxes, and gates. Instances of objects are shown as boxes at the top of the diagram. Lifelines are shown as vertical dashed lines, extending downwards from instances of the objects, to denote the passing of time. Messages, drawn as horizontal lines, denote the communication of events between objects. Action boxes, drawn as boxes on top of lifelines, denote the occurrence of activities. Gates, shown as lled circles on the boundary of the diagram, denote the occurrence of an external event. 10

Example 1. Consider the following sequence diagram from a nancial reporting system. (IBM, UML basics: The sequence diagram, http://www.ibm.com/developerworks/rational/library/ 3101.html, accessed March 10, 2011). Solid lines are initiating messages, while dashed lines are responses. We can also see synchronous messages (solid arrowheadall initiating messages in the above example) and asynchronous messages (stick arrowheadresponses). There are more elements that you can put in UML sequence diagrams, including actors (indicating interactions between the system and its users); destroy elements (indicating the end of an object instance); scenario elements (denoting a set of alternative actions); and timer elements (for discussing timed events). You can nd more information about those elements at http://www.sequencediagrameditor.com/uml/sequence-diagram.htm. Example 2. Here is another sequence diagram, again from the UML Basics site. We can note guards on the messages, which need to be satised before the message gets sent. When to use Sequence Diagrams. UML sequence diagrams help document messages going between dierent instances of objects, including the ordering in which these events occur, if applicable (for synchronous events). You need to exercise judgment to include the right level of detail; as in any model, too much detail makes the model dicult to understand, and too little detail doesn't document anything. You can use more than one UML sequence diagram to document a large system. 11