OOSE Chapter 5
OOSE Chapter 5
Design
Brain storming
What is System Design?
What are the role of the
developers in System Design?
System design is:
• During system design, developers define the design goals of the project
and decompose the system into smaller subsystems that can be realized
by individual teams.
• Developers also select strategies for building the system, such as:
• The result of system design is a model that includes a
subsystem decomposition and a clear description of each of
these strategies.
• System design is decomposed into several activities, each
addressing part of the overall problem of decomposing the
system:
Identify design goals,
Object model
A sequence diagram
• The analysis model describes the system completely from the actors’ point of view
and serves as the basis of communication between the client and the developers.
• The analysis model, however, does not contain information about the internal
structure of the system, its hardware configuration, or more generally, how the
Sub System
Object
Decomposition
design
decomposed into:
Dispatcher;
FieldOfficer;
MapManagement
IncidentManagemt
Notification
ResourceManagement
subsystems.
modifications to one of the subsystems will have little impact on the other.
• If a subsystem contains many objects that are related to each other and perform
• Layers are ordered in that each layer can depend only on lower level
• The layer that does not depend on any other layer is called the bottom
layer, and the layer that is not used by any other is called the top layer .
B:Subsystem C:Subsystem
D:Subsystem
G:Subsystem
E:Subsystem F:Subsystem
Architectural Styles
• As the complexity of systems increases, the specification of system
decomposition is critical.
• Subsystems are relatively independent and interact only through the repository.
• Control flow can be dictated either by the central repository (e.g., triggers on the
• The central location of the data makes it easier to deal with concurrency and
• The model subsystems are developed such that they do not depend on
• any view or controller subsystem. Changes in their state are propagated to the
• The MVC is a special case of the repository where Model implements the central
notifier
Subscriber
View
Client/Server Architectural Style
• In the client/server architectural style, a subsystem, the server,
RMI, or HTTP).
Peer
service1()
service2()
service3()
….
serviceN()
*
provider
Three-tier Architectural Style
• The three-tier architectural style organizes subsystems into
three layers.
The interface layer includes all boundary objects that deal with
persistent objects.
Interface Form
Query
Storage
Four- Tier Architectural Style
Query
Storage
Pipe and Filter Architectural Style
• In the pipe and filter architectural style, subsystems process data
received from a set of inputs and send results to other subsystems via a
set of outputs.
• The subsystems are called “filters,” and the associations between the
subsystems are called “pipes.”
• Each filter knows only the content and the format of the data received on
the input pipes, not the filters that produced them.
Flow of Events 1. The driver activates her computer and logs into the trip-planning Web-
Services.
2. The driver enters constraints for a trip as a sequence of destinations.
3. Based on the database of maps, the planning service computes the
shortest ways of visiting the destinations in the order specified. The
result is sequence of segments binding a series of crossing and a list of
directions.
4. The driver can receive the trip by adding or removing destinations.
5. The driver saves the planned trip by name in the planning service
database for later retrieval.
• System design consists of transforming of
Analysis model into Design Model
• There are also criteria for design decisions. These are categorized into five groups. These
include: Performance Are from
Performance Dependability Requirements
Dependability End user criteria And
Cost Application
Domain
Maintenance
End user criteria
Are from
Cost
Customer
Maintenance
And
criteria
supplier
• Performance criteria include the speed and space requirements
imposed on the system.
Should the system be responsive or should it accomplish a
maximum number of tasks?
Is memory space available for speed optimizations or should
memory be
Table 2:-Performance used sparingly?
Criteria
• Note that cost criteria not only include design considerations but managerial ones as
well.
• When the system is replacing an older one, the cost of ensuring backward
• There are also trade-offs between different types of costs such as development cost,
Upgrade cost Cost of translating data from the previous system. This criteria results
in backward compatibility requirements
Maintenance cost Cost required for bug fixes and enhancement to the system
• Maintenance criteria determine how difficult it is to change the system after deployment.
• How easily can existing functions be revised? Can the system be adapted to a different
application domain?
• How much effort will be required to port the system to a different platform?
• These criteria are harder to optimize and plan for, as it is seldom
clear how long the system will be operational and how successful
Readability How easy is it to understand the system from reading the code?
Utility (How well does the system support the user’s work?).
• Often these criteria do not receive much attention, especially when the client contracting
the system is distinct from the users of the system.
Utility How well does the system support the work of the user?
Trade-off Rationale
Space Vs. Speed If software does not meet response time or throughput requirements, more memory can
be expended to speed up the software (e.g. caching, more redundancy, etc.). If the
software does not meet memory space constraints, data can be compressed at cost of
speed.
Delivery time Vs. Functionality If the development runs behind schedule, a project manager can deliver less
functionality than specified and deliver on time, or deliver the full functionality at later
time. Contract software usually puts more emphasis on functionality, whereas off- the-
shelf software projects puts more emphasis on delivery date.
Delivery time Vs. Quality If the testing runs behind schedule, a project manager can deliver the software on time
with known bugs(and possibly provide l a later patch to fix serious bugs) or to deliver
the software late with more bugs fixed.
Delivery time Vs. Staffing If development runs behind schedule, a project manager can add resources to the project
in order to increase productivity. In most cases this option is only available early in the
project: Adding resources usually decreases productivity while new personnel is being
trained or brought up to date. Note that adding resources will also raise the cost of
development.
Identifying Sub-Systems
addressed:
Subsystems are merged into one subsystem,
a complex subsystem is split into parts, and
some subsystems are added to take care of new functionality.
functional requirements.
Example: Decomposing MyTrip System
We identify two major groups of objects: those that are involved during
the PlanTrip use cases and those that are involved during the
represent a Trip.
RoutingSubsystem.
• This leads to only one association crossing subsystem boundaries.
Trip PlanningService
RouteAssistant
Direction Destination
Location
Crossing Segment
PlanningSubsystem:
Destinations.
RoutingSubsystems.
RoutingSubsystem:
The RoutingSubsystem is responsible for downloading a Trip from the PlanningService and
• Another heuristic for subsystem identification is to keep functionally related objects together.
• A starting point is to take the use cases and assign the participating objects that have been
Assign objects identified in one use case into the same subsystem.
Create a dedicated subsystem for objects used for moving data among
subsystems
Minimize the number of associations crossing subsystem boundaries
All objects in the same subsystem should be functionally related
Encapsulating subsystems
Compile(s)
CodeGenerator
Lexer
create() getToken()
Parser
Optimizer generateParseTree()
create() ParseNode
create()
• Subsystems identified during the initial subsystem decomposition
often result from grouping several functionally related classes.
• These subsystems are good candidates for the Facade patterns and
should be encapsulated under one class.
Over view of Object design
During analysis:
• we describe the purpose of the system. This results in the identification of application
• We describe the system in terms of its architecture, such as its subsystem decomposition, its
• This results in the selection of off-the-shelf components that provide a higher level of
• We close the gap between the application objects and the off-the-shelf components by
• Analysis reduces the gap between the problem and the machine by
identifying objects representing user-visible concepts.
• During analysis, we describe the system in terms of external
behavior, such as its functionality (use case model), the application
domain concepts it manipulates (object model), its behavior in terms
of interactions (dynamic model), and its nonfunctional
requirements.
• System design reduces the gap between the problem and the machine by
defining a hardware/software platform that provides a higher level of
abstraction than the computer hardware.
• This is done by selecting off-the-shelf components for realizing standard
services, such as middleware, user interface toolkits, application
frameworks, and class libraries.
• During object design, we refine the analysis and system design models,
identify new objects, and close the gap between the application objects
and off-the-shelf components.
• This includes the identification of custom objects, the adjustment of off-
the-shelf components, and the precise specification of each subsystem
interface and class.
• As a result, the object design model can be partitioned into sets of classes
such that they can be implemented by individual developers.
1. Service specification
• It is specifying the subsystem services interms of class interfaces including:
o Operations
o Arguments
o Type of signature
o Exceptions
• It is also finding the missing operations and objects needed to transfer data among
the subsystems.
• The result of this activity complete interface specification for each subsystem.
• The subsystem system often called subsystem API
2. Component selection
• It use and adapt off-the-shelf component identified during system design to
realize each system
3. Object model restructuring
• It an activity to manipulate the system model to increase code reuse or meet other design
goals.
• Each restructuring activity can be seen as a graph transformation on subset of a particular
model.
• Typical activities includes:
o Transforming N-ary associations into binary associations.
o Merging two similar class from two d/t subsystems into single class.
o Readability
• These includes:
o Changing algorithms to respond to speed of memory requirements.
o Reducing multiplicities in associations to speed up queries.
o Add redundant association for efficiency.
o Rearrange execution orders.
o Adding derived attributes to improve access time to objects and
opening up the architecture.
o Adding access to lower layers because of performance
requirement.
Object design concepts
• the principal object design concepts are:
o Application objects versus solution objects.
o Types, signatures, and visibility
o Preconditions, post conditions, and invariants
o UML’s Object onstraint Language(OCL).
• Application objects, also called domain objects, represent concepts of the domain that the
system manipulates.
• Solution objects represent support components that do not have a counterpart in the application
domain, such as persistent data stores, user interface objects, or middleware.
• During analysis, we identify application objects, their relationships, and attributes and
operations.
• During system design, we identify subsystems and most important solution objects.
• During object design, we refine and detail both sets of objects and identify any remaining
Types, signatures, and visibility revisited
• During object design, we refine the analysis and system design models
by adding type and visibility information.
• Operation parameters and return values are typed in the same way as
attributes are.
• The type constrains the range of values the parameter or the return
value can take.
• Given an operation, the tuple made out of the types of its parameters
• The visibility of an attribute or an operation specifies whether it can be used by other
Private
• A private attribute can be accessed only by the class in which it is defined. Similarly, a
Protected
• A protected attribute or operation can be accessed by the class in which it is defined and
Public
-numElemets:int
Mapping into codes
+put(key:object, entry:object)
+get(key:object):object
+remove(key:Object)
+containsKey(key:Object):boolean class Hashtable {
+size():int
private int numElements;
/* Constructors omitted */
public void put (Object key, Object entry) {…};
public Object get(Object key) {…};
public void remove(Object key) {…};
public boolean containsKey(Object key) {…};
public int size() {…};
/* Other methods omitted */
}
Contracts: Invariants, preconditions, and post conditions
• Contracts are constraints on a class that enable caller and callee to share the same
assumptions about the class.
• A contract specifies constraints that the caller must meet before using the class as well as
constraints that are ensured by the callee when used.
An invariant is a predicate that is always true for all instances of a class. Invariants
are constraints associated with classes or interfaces. Invariants are used to specify
A post condition is a predicate that must be true after an operation is invoked. Post
conditions are associated with a specific operation. Post conditions are used to specify
constraints that the object must ensure after the invocation of the operation.
Object Control Language
• OCL is a language that allows constraints to be formally specified on single model elements (e.g.,
attributes, operations, classes) or groups of model elements (e.g., associations and participating
classes).
• A constraint is expressed as an OCL expression returning the value True or False.
• OCL is not a procedural language and thus cannot be used to denote control flow.
As we have already mentioned in the introduction, object design includes four groups
specifying constraints
specifying exceptions
realizing associations
increasing reuse
• In this step:
• In the analysis:
b/c of this the system focused on the application domain may be many attributes
polyline
1
Point
- x, y: double Polyline
- intDetailsLevels:Set points
- notDetailLevels:Set * +label: String
*
+polyline()
+point(x, y:double)
+ getPoints():Enumeration
+includeInLeveL(level:double)
+excludeFromLevel(level:double)
Adding type information to the object model of the GIS (UML class diagram). Only
selected classes shown for brevity.
Specifying constraints
• During this step:
Constraints attached to classes and operations to more
precisely specify their behavior and boundary cases.
The main goal is to remove as much ambiguity from
the model as possible.
We specify class contracts using three types of
constraints.
Invariants.
Preconditions.
Post conditions.
• completed.
Specifying exceptions
• operation.
• In other words, we specify conditions that operations detect and treat as errors by
• raising an exception.
• Languages such as Java and Ada have built-in mechanisms for exception handling.
• Other languages, such as C and early versions of C++ do not support explicit
+label: String
<<precondition>>
+layer(label: String) bbox.width>0 and
+getOutline(bbox: Rectangle2D, bbox.height>0
detail:double): Enumeration
<<precondition>>
Detail>0
<<exception>>
ZeroDetail
Examples of preconditions and exceptions for the Layer class of the JEWEL GIS.
Component selection activities
middleware frameworks,
infrastructure frameworks, or
objects as possible, thus minimizing the number of custom objects that need to be
developed.
Identifying and adjusting application frameworks
overriding predefined hook methods using patterns such as the template method
pattern.
particular interface and integrating these components with the framework, using
delegation.
• Frameworks are closely related to design patterns, class libraries, and
components.
Design patterns versus frameworks:- The main difference between
• Realizing associations
• Associations are UML concepts that denote collections of bidirectional links between two
or more objects.
• Object-oriented programming languages, however, do not provide the concept of
association.
• Instead, they provide references, in which one object stores a handle to another object.
• References are unidirectional and take place between two objects.
• During object design, we realize associations in terms of references, taking into account
the multiplicity of the associations and their direction.
Qualified Associations
Increasing reuse
• Inheritance allows developers to reuse code across a number of similar classes, For
example, JFC, as do most user interface toolkits, provides four types of buttons:
A push button (JButton), which triggers an action when the end user clicks on the
button
A radio button (JRadioButton), which enables an end user to select one choice out of a
set of options
A menu item (JMenuItem), which triggers an action when selected from a pull down or
JRadioButton JCheckBox
• There are two main advantages to using a well-designed inheritance hierarchy.
1. Code is reused, leading to less redundancies and thus fewer opportunities for
defects.
• There are two main approaches to designing an inheritance hierarchy for reuse.
behavior.
of abstraction.
Optimization activities
• The direct translation of an analysis model results into a model that is often inefficient.
• During object design, the object model optimized according to design goals, such as
minimization of response time, execution time, or memory resources. The four simple
optimizations:
• When applying optimizations, developers must strike a balance between efficiency and
clarity.
• Optimizations increase the efficiency of the system but also make it more complex and
Managing object Design
• There are two primary management challenges
during object design:
• Increase communication complexity:-
• Consistency with prior decision and documents
Documenting object design
• It describes:
class interfaces.
• The audience for the ODD includes system architects, (i.e., the developers
who participate in the system design), developers who implement each
• The ODD enables developers to understand the subsystem sufficiently
well that they can use it.
• Moreover, a good interface specification enables other developers to
implement classes concurrently.
• In general, an interface specification should satisfy the following
criteria:
Restrictiveness
Generality
Clarity