Topics covered Design and implementation Build or buy Object

advertisement
2/23/2016
Chapter 7 Design and implementation
1
Topics covered
2



Object-oriented design
Design patterns
Implementation issues
CHAPTER 7 – DESIGN AND IMPLEMENTATION
Qinghua Li
Chapter 7 Design and implementation
Design and implementation
3
Build or buy
4

Design and implementation is the stage at which an
executable software system is developed

 Software
design: identify software components and
their relationships, based on a customer’s requirements
 Implementation: realizing the design as a program

 E.g.,
a medical records system
and maybe cheaper
 Faster
Design and implementation activities are interleaved

Object-oriented design
5
In many domains, you can buy commercial off-theshelf systems (COTS) that can be tailored to the
users’ requirements
In this way, the design process focuses on
configuring that system to deliver the user
requirements
www.dallassprinklerrepairtx.com
Wilderness weather station
6

Easier to change
include data and operations
 Changing the implementation of one object may not
affect other system objects

 Objects


Designing object classes and relationships between
them

The government deploys several
hundred weather stations in remote
areas
Weather stations collect data from a
set of instruments that measure
temperature, pressure, etc., do initial
data processing such as aggregation,
and send data to remote data
management system
External systems


data management and archiving system
station maintenance system
commons.wikimedia.org
1
2/23/2016
Context and interaction models
Object-oriented design process stages
7
8

Activities
 Define

the context and external interactions with the
system
 Design
the system architecture
the principal system objects
 Develop design models
 Specify object interfaces

 Identify
A system context model is a structural model that
demonstrates the other related systems in the
environment of the system being developed
An interaction model is a dynamic
y
model that shows
how the system interacts with its environment as it is
used.
Chapter 7 Design and implementation
Weather station use cases
System context for the weather station
9
10
Use case description—Report weather
11
Object-oriented design process stages
12
System
Weather station
Use case
Report weather
Actors
Weather information system, Weather station
Description
The weather station sends a summary of the weather data that has been
collected from the instruments in the collection period to the weather information
system. The data sent are the maximum
system
maximum, minimum
minimum, and average ground and air
temperatures; the maximum, minimum, and average air pressures; the maximum,
minimum, and average wind speeds; the total rainfall; and the wind direction as
sampled at five-minute intervals.
Stimulus
The weather information system establishes a satellite communication link with
the weather station and requests transmission of the data.
Response
The summarized data is sent to the weather information system.
Comments
Weather stations are usually asked to report once per hour but this frequency
may differ from one station to another and may be modified in the future.

Activities
 Define
the context and external interactions with the
system
 Design the system architecture
 Identify the principal system objects
 Develop design models
 Specify object interfaces
2
2/23/2016
Architectural design
13
14


High-level architecture of the weather
station
Identify the major components and their interactions
May organize the components using an architectural
pattern
Architecture of data collection system
15
Object-oriented design process stages
16

Activities
 Define
the context and external interactions with the
system
 Design the system architecture
 Identify the principal system objects
 Develop design models
 Specify object interfaces
Object class identification
17
Approaches to identification
18

Often a difficult part of object oriented design
is no 'magic formula' for object identification. It
relies on the skill, experience and domain knowledge of
system designers
 Object identification is an iterative process

 There
Use a grammatical approach based on a natural language
description of the system




Noun: possible object
Verb: possible method
Base the identification on tangible things in the application
domain
Use a scenario-based analysis. The objects, attributes and
methods in each scenario are identified.
3
2/23/2016
Weather station description
19
Weather station object classes
20

A weather station is a package of software controlled instruments
which collects data, performs some data processing and transmits
this data for further processing. The instruments include air and
ground thermometers,, an anemometer,, a wind vane,, a barometer
g
and a rain gauge. Data is collected periodically.
Object class identification based on the tangible
hardware and data in the system:

Ground thermometer, Anemometer, Barometer


Weather station

When a command is issued to transmit the weather data, the
weather station processes and summarises the collected data. The
summarised data is transmitted to the mapping computer when a
request is received.

The basic interface of the weather station to its environment. It therefore
reflects the interactions identified in the use-case model.
Weather data

Weather station object classes
21
Application domain objects that are ‘hardware’ objects related to the
instruments in the system.
Encapsulates the summarized data from the instruments.
Object-oriented design process stages
22

Activities
 Define
the context and external interactions with the
system
 Design the system architecture
 Identify the principal system objects
 Develop design models
 Specify object interfaces
Design models
23
Examples of design models
24



Design models show the objects and object classes
and relationships between these entities.
Static models describe the static structure of the
system
y
in terms of object
j classes and relationships
p
Dynamic models describe the dynamic interactions
between objects.



Subsystem models that show logical groupings of objects into
coherent subsystems.
Sequence models that show the sequence of object interactions.
State machine models that show how individual objects change
th i state
their
t t in
i response to
t events.
t
4
2/23/2016
Subsystem models
25
Sequence models
26

Shows how the design is organised into logically
related groups of objects.

Sequence models show the sequence of object
interactions that take place
 Objects
are arranged horizontally across the top;
is represented vertically so models are read top
t bottom;
to
b tt
 Interactions are represented by labelled arrows
 Time
27
Sequence diagram describing data
collection
State diagrams
28

State diagrams are used to show how objects
respond to different service requests and the state
transitions triggered by these requests.
 Useful
high-level models of a system or an object’s runtime behavior.
behavior
 You don’t usually need a state diagram for all objects
Weather station state diagram
29
Object-oriented design process stages
30

Activities
 Define
the context and external interactions with the
system
 Design the system architecture
 Identify the principal system objects
 Develop design models
 Specify object interfaces
5
2/23/2016
Interface specification
31
Weather station interfaces
32




Interfaces: what an object can do
Object interfaces have to be specified so that the objects and
other components can be designed in parallel.
Designers should avoid designing the interface representation
b t should
but
h ld hid
hide thi
this in
i the
th object
bj t itself.
it lf
Objects may have several interfaces which are viewpoints on
the methods provided.
Questions?
Design patterns
33
34

A design pattern is a way of reusing abstract
knowledge about a problem and its solution
"Each pattern describes a problem which occurs
over and over again in our environment,
environment and
then describes the core of the solution to that
problem, in such a way that you can use this
solution a million times over, without ever doing
it the same way twice”
– Christopher Alexander
Chapter 7 Design and implementation
Pattern elements
35
The Observer pattern
36

Name
A


Name

Description

meaningful pattern identifier
Problem description

 When

Solution description
a concrete design but a template for a design
solution that can be instantiated in different ways
Consequences
 The

the pattern is applicable
 Not


results and trade-offs of applying the pattern
Observer.
Separates the display of object state from the object itself
allows alternative displays to be provided
When the object
j state changes,
g , all displays
p y are automaticallyy notified and
updated to reflect the change

Problem description

Solution description

Consequences



Used when multiple displays of state are needed.
See slide with UML description.
Optimisations to enhance display performance are impractical.
Chapter 7 Design and implementation
6
2/23/2016
37
Multiple displays using the Observer
pattern
A UML model of the Observer pattern
38
Design problems and patterns
39
Design problems (cont’d)
40




Tell several objects that the state of some other
object has changed: Observer pattern
Provide a standard way of accessing the elements
in a collection, irrespective of how that collection is
i l
implemented:
d Iterator
It t pattern
tt
Allow for the possibility of extending the
functionality of an existing class at run-time:
Decorator pattern
Ensure a class has only one instance, and provide a
global point of access to it: Singleton pattern
 Represent
an operation to be performed on the
elements of an object structure, and define a new
operation without changing the classes of the elements
on which it operates: Visitor pattern

 Design
Patterns: Elements of Reusable Object-Oriented
Software
 Erich
Gamma, Richard Helm, Ralph Johnson, John Vlissides
of Four”
 “Gang
 Wiki:
Implementation issues
41
More resources
Software design pattern
Reuse
42



Reuse Most modern software is constructed by
reusing existing components or systems
Configuration management Keep track of the many
different versions of each software component
p
Development tools Tools that enable more efficient
development

From the 1960s to the 1990s, most new software
was developed from scratch
 The
only significant reuse was the reuse of functions and
objects in programming language libraries

Costs and schedule pressure rendered this
approach infeasible, especially for commercial and
Internet-based systems
7
2/23/2016
Reuse levels
43
Reuse costs
44

The abstraction level


Reuse objects from a library rather than writing the code
yourself

The component level



The object level



Reuse knowledge of successful abstractions in the design,
e.g., architecture pattern

Reuse collections of objects which are called components of
application systems
The costs of the time spent in looking for proper
reusable software
The costs of buying the reusable software
The costs of adapting and configuring the reusable
software components/systems for your system
The costs of integrating reusable software elements
with each other and with your new code
The system level

Reuse entire application systems
Configuration management
45
Configuration management activities
46

The general process of managing a changing
software system

 Change
by different people
 Change
g at different times

Version management

keep track of the different versions of software components.

coordinate development by several programmers.
System integration


help developers define what versions of components are used to create
each version of a system
Problem tracking

allow users to report bugs and other problems

allow all developers to see who is working on these problems and when
they are fixed
Chapter 7 Design and implementation
Configuration management Tools
47
Development tools
48

Comprehensive tools



ClearCase
Separate tools
 Version
control: Subversion
 System integration: GNU build (Unix make)
 Bug tracking: Bugzilla




An integrated compiler and syntax-directed editing
system that allows you to create, edit and compile
code.
A language debugging system.
Graphical editing tools, such as tools to edit UML
models.
Testing tools, such as Junit that can automatically run
a set of tests on a new version of a program.
Project support tools that help you organize the
code for different development projects
Chapter 7 Design and implementation
8
2/23/2016
49
Integrated development environments
(IDEs)

Software development tools are often grouped to
create an IDE
 NetBeans,

Eclipse, Microsoft Visual Studio
IDEs are created to support development in a
specific programming language such as Java
9
Download