0% found this document useful (0 votes)
20 views

Lecture 2

This lecture introduces modeling complex systems using the Unified Modeling Language (UML). It discusses how abstraction, decomposition, and hierarchy can be used to deal with complexity. The lecture then provides an overview of UML diagrams including use case diagrams, class diagrams, sequence diagrams, statechart diagrams, and activity diagrams.

Uploaded by

Emmad Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Lecture 2

This lecture introduces modeling complex systems using the Unified Modeling Language (UML). It discusses how abstraction, decomposition, and hierarchy can be used to deal with complexity. The lecture then provides an overview of UML diagrams including use case diagrams, class diagrams, sequence diagrams, statechart diagrams, and activity diagrams.

Uploaded by

Emmad Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Lecture 2: Modeling with UML- Part 1

Ebrahim Karami
ENGI-9874
Software Specification and Design
Overview for the Lecture
Three ways to deal with complexity
Abstraction and Modeling
Decomposition
Hierarchy
Introduction into the UML notation
First pass on:
Use case diagrams
Class diagrams
Sequence diagrams
Statechart diagrams
Activity diagrams
What is the problem with this Drawing?
Abstraction

• Complex systems are hard to understand


• The 7 +- 2 phenomena
• Our short term memory usually cannot store more
than 7+-2 pieces at the same time -> limitation of
the brain
• A Phone Number: 498928918204
Abstraction
• Complex systems are hard to understand
• The 7 +- 2 phenomena
• Our short term memory cannot store more than 7+-2
pieces at the same time -> limitation of the brain
• A Phone Number: 498928918204

• Chunking:
• Group collection of objects to reduce complexity
• 4 chunks:
• State-code, Area-code, Local-Prefix, Internal-Nr
Abstraction
• Complex systems are hard to understand
• The 7 +- 2 phenomena
• Our short term memory cannot store more than 7+-2
pieces at the same time -> limitation of the brain
• A Phone Number: 498928918204

• Chunking:
• Group collection of objects to reduce complexity
• State-code, Area-code, Local Prefix, Internal-Nr

Phone Number

Country-Code Area-Code Local-Prefix Internal-Nr


Abstraction
• Abstraction allows us to ignore unessential details
• Two definitions for abstraction:
• Abstraction is a thought process where ideas are
distanced from objects
• Abstraction as activity
• Abstraction is the resulting idea of a thought process
where an idea has been distanced from an object
• Abstraction as entity
• Ideas can be expressed by models
Model
A model is an abstraction of a
system
A system that no longer exists
An existing system
A future system to be built.
We use Models to describe Software
Systems

Object model: What is the structure of the


system?
Functional model: What are the functions of
the system?
Dynamic model: How does the system react
to external events?

System Model: Object model + functional


model + dynamic model
Other models used to describe Software
System Development
Task Model:
PERT Chart: What are the dependencies between
tasks?
Schedule: How can this be done within the time
limit?
Organization Chart: What are the roles in the
project?
Issues Model:
What are the open and closed issues?
 What blocks me from continuing?
What constraints were imposed by the client?
What resolutions were made?
 These lead to action items
2. Technique to deal with Complexity:
Decomposition
A technique used to master complexity (“divide
and conquer”)
Two major types of decomposition
Functional decomposition
Object-oriented decomposition
Functional decomposition
The system is decomposed into modules
Each module is a major function in the
application domain
Modules can be decomposed into smaller
modules.
Decomposition (cont’d)
Object-oriented decomposition
The system is decomposed into classes (“objects”)
Each class is a major entity in the application domain
Classes can be decomposed into smaller classes

Object-oriented vs. functional decomposition

Which decomposition is the right one?


Functional Decomposition
System
Function Top Level functions

Produce
Read Input Transform Level 1 functions
Output

Produce Level 2 functions


Read Input Transform
Output

Load R10 Add R1, R10 Machine instructions


Functional Decomposition
The functionality is spread all over the system
Maintainer must understand the whole system to make a single
change to the system
Consequence:
Source code is hard to understand
Source code is complex and impossible to maintain
User interface is often awkward and non-intuitive.
Functional Decomposition
The functionality is spread all over the system
Maintainer must understand the whole system to make a single
change to the system
Consequence:
Source code is hard to understand
Source code is complex and impossible to maintain
User interface is often awkward and non-intuitive

• Example: Microsoft Powerpoint’s Autoshapes


• How do I change a square into a circle?

?
Functional Decomposition: Autoshape
Autoshape

Change Draw

Change Change Change


Rectangle Oval Circle

Draw Draw Draw


Rectangle Oval Circle
Object-Oriented View

Autoshape

Draw()
Change()
What is This?

An Eskimo!
Cave

Ellbow Neck
Glove
Pocket
Coat
A Face!
Hair

Eye
Nose
Ear
Mouth
Chin
An Eskimo! A Face!

Cave Hair

Neck Eye
Ellbow Nose
Glove Ear
Pocket Mouth
Coat Chin
Class Identification
Basic assumptions:
We can find the classes for a new software
system: Greenfield Engineering
We can identify the classes in an existing
system: Reengineering
We can create a class-based interface to an
existing system: Interface Engineering
3. Hierarchy
So far we got abstractions
This leads us to classes and objects
“Chunks”

• Another way to deal with complexity is to


provide relationships between these chunks
• One of the most important relationships is
hierarchy
• 2 special hierarchies
• "Part-of" hierarchy
• "Is-kind-of" hierarchy
Part-of Hierarchy (Aggregation)
Computer

I/O Devices CPU Memory

Cache ALU Program


Counter
Is-Kind-of Hierarchy (Taxonomy)
Cell

Muscle Cell Blood Cell Nerve Cell

Striate Smooth Red White Cortical Pyramidal


Concepts and Phenomena
Phenomenon
An object in the world of a domain as you perceive it
 Examples: This lecture at 9:35, my black watch

Concept
Describes the common properties of phenomena
 Example: All lectures on software engineering
 Example: All black watches

A Concept is a 3-tuple:
Name: The name distinguishes the concept from other
concepts
Purpose: Properties that determine if a phenomenon is a
member of a concept
Members: The set of phenomena which are part of the
concept.
Concepts, Phenomena, Abstraction and Modeling
Name Purpose Members

Watch A device that


measures time.

Definition Abstraction:
 Classification of phenomena into concepts

Definition Modeling:
 Development of abstractions to answer specific questions about a set of phenomena while
ignoring irrelevant details.
Abstract Data Types & Classes Superclass

Abstract data type State


A type whose implementation is hidden Watch
from the rest of the system
Class: time
date
An abstraction in the context of object-
SetDate(d)
oriented languages
A class encapsulates state and behavior
Behavior
 Example: Watch

Inheritance CalculatorWatch

calculatorState
Unlike abstract data types, subclasses
can be defined in terms of other EnterCalcMode()
classes using inheritance InputNumber(n)

• Example: CalculatorWatch
Subclass
Type and Instance
Type:
A concept in the context of programming languages
Name: int
Purpose: integral number
Members: 0, -1, 1, 2, -2,…
Instance:
Member of a specific type

The type of a variable represents all possible instances


of the variable
The following relationships are similar:
Type <–> Variable
Concept <–> Phenomenon
Class <-> Object
Systems
A system is an organized set of communicating parts
Natural system: A system whose ultimate purpose is not known
Engineered system: A system which is designed and built by engineers for a specific purpose
The parts of the system can be considered as systems again
In this case we call them subsystems

Examples of natural systems:


• Universe, earth, ocean
Examples of engineered systems:
• Airplane, watch, GPS
Examples of subsystems:
• Jet engine, battery, satellite.
Systems, Models and Views
• A model is an abstraction describing a system or a subsystem

• A view depicts selected aspects of a model


• A notation is a set of graphical or textual
rules for depicting models and views:
• formal notations, “napkin designs”

System: Airplane

Models:
Flight simulator Views:
Scale model Blueprint of the airplane components
Electrical wiring diagram, Fuel system
Sound wave created by airplane
(UML Notation)
Class Diagram
* *
System Model View
Described by Depicted by

Airplane:
System
Object Diagram

Scale Model:Model Flight Simulator:Model

Blueprints: Fuel System: Electrical Wiring:


View View View
Model-Driven Development
1. Build a platform-independent model of an applications
functionality and behavior
a) Describe model in modeling notation (UML)
b) Convert model into platform-specific model
2. Generate executable from platform-specific model
Advantages:
 Code is generated from model (“mostly”)
 Portability and interoperability
 Model Driven Architecture effort:
 http://www.omg.org/mda/
 OMG: Object Management Group
Model-driven Software Development
Reality: A stock exchange lists many companies. Each
company is identified by a ticker symbol

Analysis results in analysis object model (UML Class Diagram):


StockExchange * * Company
Lists tickerSymbol

Implementation results in source code (Java):


public class StockExchange {
public m_Company = new Vector();
};
public class Company {
public int m_tickerSymbol;
public Vector m_StockExchange = new Vector();
};
Application vs Solution Domain
Application Domain (Analysis):
The environment in which the system is operating

Solution Domain (Design, Implementation):


The technologies used to build the system

Both domains contain abstractions that we can use for


the construction of the system model.
Object-oriented Modeling

Application Domain Solution Domain


(Phenomena) (Phenomena)

System Model (Concepts)(Analysis) System Model (Concepts)(Design)


UML Summary
Package MapDisplay Display
TrafficControl

TrafficController FlightPlanDatabase
Aircraft
TrafficControl
Airport FlightPlan
What is UML?
UML (Unified Modeling Language)
Nonproprietary standard for modeling software systems, OMG
Convergence of notations used in object-oriented methods
 OMT (James Rumbaugh and collegues)
 Booch (Grady Booch)
 OOSE (Ivar Jacobson)

Current Version: UML 2.2


Information at the OMG portal http://www.uml.org/
Commercial tools: Rational (IBM),Together (Borland), Visual Architect
(business processes, BCD)
Open Source tools: ArgoUML, StarUML, Umbrello
Commercial and Opensource: PoseidonUML (Gentleware)
UML: First Pass
You can model 80% of most problems by using about
20 % UML
We teach you those 20%

80-20 rule: Pareto principle


http://www.ephorie.de/hindle_pareto-prinzip.htm
UML First Pass
Use case diagrams
Describe the functional behavior of the system as seen by the user
Class diagrams
Describe the static structure of the system: Objects, attributes,
associations
Sequence diagrams
Describe the dynamic behavior between objects of the system
Statechart diagrams
Describe the dynamic behavior of an individual object
Activity diagrams
Describe the dynamic behavior of a system, in particular the
workflow.
UML Core Conventions
All UML Diagrams denote graphs of nodes and edges
Nodes are entities and drawn as rectangles or ovals
Rectangles denote classes or instances
Ovals denote functions

• Names of Classes are not underlined


• SimpleWatch
• Firefighter
• Names of Instances are underlined
• myWatch:SimpleWatch
• Joe:Firefighter
• An edge between two nodes denotes a
relationship between the corresponding entities
UML first pass: Use case diagrams
Classifier
Use Case

Actor.

System boundary

Use case diagrams represent the functionality of the system


from user’s point of view
Historical Remark: UML 1 used packages
Package Use case
Watch

Actor
ReadTime

SetTime
WatchUser WatchRepairPerson

ChangeBattery

Use case diagrams represent the functionality of the system


from user’s point of view
UML first pass: Class diagrams
Association
Class

Multiplicity
SimpleWatch
1 1 1 1
2 1 2 1
PushButton Display Battery Time

Class diagrams represent the structure of the system


UML first pass: Class diagrams
Class diagrams represent the structure of the system

Association
Class

Multiplicity Watch
1 1 1 1
2
1 2 1
PushButton
state LCDDisplay Battery Time
blinkIdx Load Now
push() blinkSeconds()
release() blinkMinutes()
blinkHours()
stopBlinking()
Operations
Attribute referesh()
UML first pass: Sequence diagram
Actor Message Object Lifeline
:WatchUser :Watch :LCDDisplay :Time
pressButton1() blinkHours()
pressButton1()
blinkMinutes()
pressButton2()
incrementMinutes()
refresh()
pressButton1and2()
commitNewTime()
stopBlinking()
Activation

Sequence diagrams represent the behavior of a system


as messages (“interactions”) between different objects
UML first pass: Statechart diagrams
Event Initial state
button1&2Pressed button2Pressed
Blink Increment
Hours Hours

Transition button1Pressed

button1&2Pressed button2Pressed
Blink Increment
Minutes Minutes
State
button1Pressed

button2Pressed
Stop Blink Increment
Blinking Seconds Seconds

Final state

Represent behavior of a single object with interesting


dynamic behavior.
Other UML Notations
UML provides many other notations, for example
Deployment diagrams for modeling configurations
Useful for testing and for release management
We introduce these and other notations as we go along
in the lectures
OCL: A language for constraining UML models
What should be done first? Coding or Modeling?
It all depends….
Forward Engineering
Creation of code from a model
Start with modeling
Greenfield projects
Reverse Engineering
Creation of a model from existing code
Interface or reengineering projects
Roundtrip Engineering
Move constantly between forward and reverse engineering
Reengineering projects
Useful when requirements, technology and schedule are changing
frequently.
UML Basic Notation Summary
UML provides a wide variety of notations for modeling
many aspects of software systems
Today we concentrated on a few notations:
Functional model: Use case diagram
Object model: Class diagram
Dynamic model: Sequence diagrams, statechart
Additional References
Martin Fowler
UML Distilled: A Brief Guide to the Standard Object Modeling
Language, 3rd ed., Addison-Wesley, 2003
Grady Booch,James Rumbaugh,Ivar Jacobson
The Unified Modeling Language User Guide, Addison Wesley, 2nd
edition, 2005
Commercial UML tools
Rational Rose XDE for Java
 http://www-306.ibm.com/software/awdtools/developer/java/

Together (Eclipse, MS Visual Studio, JBuilder)


 http://www.borland.com/us/products/together/index.html

Open Source UML tools


http://java-source.net/open-source/uml-modeling
ArgoUML,UMLet,Violet, …

You might also like