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

SoftwareEngineering Fall24 L2

Uploaded by

Ahmed Farid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

SoftwareEngineering Fall24 L2

Uploaded by

Ahmed Farid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

CIE 460

Fundamentals of Software
Engineering
Software Modeling
Lecture 2

Manar Elkady, Ph.D.


Object-Oriented Software Engineering
Using UML, Patterns, and Java
Chapter 2,
Modeling with UML, Part 1
Overview for the Lecture

• Three ways to deal with complexity


• Abstraction and Modeling
• Decomposition
• Hierarchy
• Object-oriented vs. functional decomposition
• System, Model, View
• Model-Driven Development
• Object-Oriented Modeling
• Application vs Solution Domain

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
What is the problem with this Drawing?

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
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
• Phone Number: 2023350190780

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
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
• Phone Number: 2023350190780

• Chunking:
• Group collection of objects to reduce complexity
• 4 chunks:
• Country-code, city-code, Place-code, Office-Part

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
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
• Phone Number: 2023350190780

• Chunking:
• Group collection of objects to reduce complexity
• Country-code, city-code, Place-code, Office-Part

Phone Number

State-Code City-Code Place-code Office-Part


Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
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
• Phone Number: 2023350190780

• Chunking:
• Group collection of objects to reduce complexity
• Country-code, city-code, Place-code, Office-Part

Phone Number

20 2 335-0190 780
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
Model
• A model is an abstraction of a
system
• A system that no longer exists
• An existing system
• A future system to be built.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
Object-oriented vs. functional
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.

• 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

Which decomposition is the right one?


Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
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.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
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?

?
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Functional Decomposition: Autoshape
Autoshape

Change Draw

Change Change Change


Rectangle Oval Circle

Draw Draw Draw


Rectangle Oval Circle

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
Object-Oriented View

Autoshape

Draw()
Change()

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18
What is This?

An Eskimo!
Cave

Neck
Ellbow
Glove
Pocket
Coat

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19
A face
Hair

Eye
Nose
Ear
Mouth
Chin

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
An Eskimo! A Face!

Cave Hair

Neck Eye
Ellbow Nose
Glove Ear
Pocket Mouth
Coat Chin

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
Class Identification (cont’d)
• Can we do this?
• Yes - science, experimental evidence
• What are the limitations?
• Depending on the purpose of the system,
different objects might be found
• Crucial
Identify the purpose of a system

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
Modeling a Briefcase

BriefCase

Capacity: Integer
Weight: Integer What is this thing?

Open()
Close()
Carry()

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
A New Use of a Briefcase

BriefCase

Capacity: Integer
Weight: Integer

Open()
Close()
Carry()
SitOnIt()

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
Part-of Hierarchy (Aggregation)
Computer

I/O Devices CPU Memory

Cache ALU Program


Counter

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
Is-Kind-of Hierarchy (Taxonomy)

Cell

Muscle Cell Blood Cell Nerve Cell

Striate Smooth Red White Cortical Pyramidal

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
Systems
• A system is an organized set of communicating parts
• Natural system: A system whose ultimate purpose is not
agreed upon
• 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.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
Systems, Models and Views (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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
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

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
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();
};
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
Object-oriented Modeling

Application Domain Solution Domain


(Phenomena) (Phenomena)

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


UML Summary
Package MapDisplay Display
TrafficControl
FlightPlanDatabase
Aircraft TrafficController
TrafficControl
Airport FlightPlan
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
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.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36

You might also like