Module 3
Module 3
MODULE – 3
SOFTWARE DESIGN
Software Design
Architectural Design
• Establishing the overall Structure of a software system.
Objectives
• To introduce software engineering and to explain its
importance
• To set out the answers to key questions about software
engineering
• To introduce ethical and professional issues and to explain why
they are of concern to software engineers
Software architecture
• The design process for identifying the sub-systems making up a
system and the framework for sub-system control and
communication is the architectural design
• The output of this design process is a description of the
software architecture
Architectural design
• An early stage of the system design process
• Represents the link between specification and design processes
• Often carried out in parallel with some specification activities
• It involves identifying major system components and their
communications
Architectural models
• Different architectural models may be produced during the design
process
• Each model presents different perspectives on them architecture
• Static structural model that shows the major system components
• Dynamic process model that shows the process structure of the system
• Interface model that defines sub-system interfaces
• Relationships model such as a data-flow model
Architectural styles
Packaging
selection
system
Packing Conveyor
system controller
System Organization
Design Report
analyser generator
Advantages
• Efficient way to share large amounts of data
• Sub-systems need not be concerned with how data is produced
• Centralized management e.g. backup, security, etc.
• Sharing model is published as the repository schema
Disadvantages
• Sub-systems must agree on a repository data model. Inevitably
a compromise
• Data evolution is difficult and expensive
• No scope for specific management policies
• Difficult to distribute efficiently
Client-server architecture
• Distributed system model which shows how data and
processing is distributed across a range of components
Client 1
I Client 2 Client 3 Client 4
Wide-bandwidth network
Client-server characteristics
Advantages
• Distribution of data is straightforward
• Makes effective use of networked systems. May require
cheaper hardware
• Easy to add new servers or upgrade existing servers
Disadvantages
• No shared data model so sub-systems use different data
organization. Data interchange may be inefficient
• Redundant management in each server
• No central register of names and services - it may be hard to
find out what servers and services are available
Database system
Operating
system
Control Styles
Control models: Are concerned with the control flow between sub-systems.
Distinct from the system decomposition model
• Centralized control: One sub-system has overall responsibility
for control and starts and stops other sub-systems
• Event-based control: Each sub-system can respond to
externally generated events from other sub-systems or the system’s
environment
Centralized control
• A control sub-system takes responsibility for managing the
execution of other sub-systems
• Call-return model: Top-down subroutine model where control
starts at the top of a subroutine hierarchy and moves downwards.
Applicable to sequential systems
• Manager model: Applicable to concurrent systems. One system
component controls the stopping, starting and coordination of other
system processes. Can be implemented in sequential systems as a
case statement
Call-return model
I Main
program
I
Sensor Actuator
processes processes
System
controller
Event-driven systems:
Driven by externally generated events where the timing of the
event is outwit the control of the sub-systems which process the
event.
Broadcast model
• Effective in integrating sub-systems on different computers in a
network
• Sub-systems register an interest in specific events. When these
occur, control is transferred to the sub-system which can handle the
event
• Control policy is not embedded in the event and message
handler. Sub-systems decide on events of interest to them
• However, sub-systems don’t know if or when an event will be
handled
Selective broadcasting
I
Sub-system Sub-system Sub-system Sub-system
1 2 3 4
Interrupt-driven systems
• Used in real-time systems where fast response to an event is essential
• There are known interrupt types with a handler defined for each type
• Each type is associated with a memory location and a hardware switch
causes transfer to its handler
• Allows fast response but complex to program and difficult to validate
Interrupt-driven control
Interrupts
I
Interrupt
vector
Object models
• Structure the system into a set of loosely coupled objects with
well-defined interfaces
• Object-oriented decomposition is concerned with identifying
object classes, their attributes and operations
• When implemented, objects are created from these classes and
some control model used to coordinate object operations
Data-flow models
• Functional transformations process their inputs to produce
outputs
• May be referred to as a pipe and filter model (as in UNIX shell)
• Variants of this approach are very common. When
transformations are sequential, this is a batch sequential model
which is extensively used in data processing systems
• Not really suitable for interactive systems
Domain-specific architectures
• Architectural models which are specific to some application
domain
• Two types of domain-specific model
• Generic models which are abstractions from a number of real
systems and which encapsulate the principal characteristics of these
systems
• Reference models which are more abstract, idealized model.
Provide a means of information about that class of system and of
comparing different architectures
• Generic models are usually bottom-up models; Reference
models are top-down models
Object-oriented Design
• Designing systems using self- contained objects and object
classes
Characteristics of OOD
• Objects are abstractions of real-world or system entities and
manage themselves
• Objects are independent and encapsulate state and
representation information.
• System functionality is expressed in terms of object services
Advantages of OOD
• Easier maintenance. Objects may be understood as stand-alone entities
• Objects are appropriate reusable components.
• For some systems, there may be an obvious mapping from real world
entities to system objects
Object-oriented development
• Object-oriented analysis, design and programming are related but
distinct
• OOA is concerned with developing an object model of the application
domain
• OOD is concerned with developing an object-oriented system model to
implement requirements
• OOP is concerned with realizing an OOD using an OO programming
language such as Java or C++
Objects
• An Object is an entity which has a state and a defined set of operations
which operate on that state. The state is represented as a set of object
attributes. The operations associated with the object provide services to
other objects (clients) which request these services when some
computation is required.
all the attributes and services which should be associated with an object of
that class.
Object communication
• Conceptually, objects communicate by message passing.
• Messages
• The name of the service requested by the calling object.
• Copies of the information required to execute the service and
the name of a holder for the result of the service.
• In practice, messages are often implemented by procedure calls
• Name = procedure name.
• Information = parameter list.
Message examples
// Call a method associated with a buffer
// object that returns the next value
// in the buffer
v = circularBuffer.Get ();
// Call the method associated with a
// thermostat object that sets the
// temperature to be maintained
thermostat.setTemp (20);
A generalization hierarchy
I
Advantages of inheritance
• It is an abstraction mechanism which may be used to classify
entities
• It is a reuse mechanism at both the design and the programming
level
• The inheritance graph is a source of organizational knowledge
about domains and systems
UML associations
• Objects and object classes participate in relationships with
other objects and object classes
• In the UML, a generalized relationship is indicated by an
association
• Associations may be annotated with information that describes
the association Associations are general but may indicate that an
attribute of an object is an associated object or that a method relies
on an associated object
An association model
Coords c1, c2 ;
Satellite sat1, sat2 ;
Navigator theNavigator ;
public Position givePosition ()
{
return currentPosition ;
}
Concurrent objects
• The nature of objects as self-contained entities make them
suitable for concurrent implementation
• The message-passing model of object communication can be
implemented directly if objects are running on separate processors
in a distributed system
Java threads
• Threads in Java are a simple construct for implementing
concurrent objects
• Threads must include a method called run() and this is started
up by the Java run-time system
Layered architecture
Use-case description
System Weather station
Use-case Report
Actors Weather data collection system,
Weather station
Data The weather station sends a
summary of the weather data that
has been collected from the
instruments in the collection
period to the weather data
collection system. The data sent
are the maximum minimum and
average ground and air
temperatures, the maximum,
minimum and average air
pressures, the maximum,
minimum and average wind
Object identification
• Identifying objects (or object classes) is the most difficult part
of object oriented design
• There 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. You are unlikely to
get it right first time
Approaches to identification
• Use a grammatical approach based on a natural language
description of the system (used in Hood method)
• Base the identification on tangible things in the application
domain
• Use a behavioral approach and identify objects based on what
participates in what behavior
• Use a scenario-based analysis. The objects, attributes and
methods in each scenario are identified
Design models
• Design models show the objects and object classes and
relationships between these entities
• Static models describe the static structure of the system in
terms of object classes and relationships
• Dynamic models describe the dynamic interactions between
objects.
Examples of design models
• Sub-system 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
their state in response to events
• Other models include use-case models, aggregation models,
generalization models, etc.
Subsystem models
• Shows how the design is organized into logically related groups
of objects
• In the UML, these are shown using packages – an
encapsulation construct. This is a logical model. The actual
organization of objects in the system may be different.
IWeather station subsystems
Sequence models
• Sequence models show the sequence of object interactions that
take place
• Objects are arranged horizontally across the top
• Time is represented vertically so models are read top to bottom
• Interactions are represented by labeled arrows, Different styles
of arrow represent different types of interaction
Statecharts
• Show how objects respond to different service requests and the state
transitions triggered by these requests
• If object state is Shutdown then it responds to a Startup() message In
the waiting state the objec t is waiting for further messages
• If reportWeather () then system moves to summarizing state
• If calibrate () the system moves to a calibrating state
• A collecting state is entered when a clock signal is received
Design evolution
• Hiding information inside objects means that changes made to an object
do not affect other objects in an unpredictable way
• Assume pollution monitoring facilities are to be added to weather
stations. These sample the air and compute the amount of different
pollutants in the atmosphere
• Pollution readings are transmitted with weather data
Changes required
• Add an object class called ‘Air quality’ as part of
WeatherStation
• Add an operation reportAirQuality to WeatherStation. Modify
the control software to collect pollution readings
• Add objects representing pollution monitoring instruments
Pollution monitoring