Nothing Special   »   [go: up one dir, main page]

Chap 5.3OODesign222

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

Chapter 5

Object-Oriented Software Engineering

5.3 Object Oriented Design

1
Object Oriented Design
• Designing object-oriented software is hard, and
designing reusable object-oriented software is even
harder.
• Your design should be specific to the problem at hand
but also general enough to address future problems and
requirements.
• You also want to avoid redesign, or at least minimize
it.
• Before a design is finished, they usually try to reuse it
several times, modifying it each time.

2
Object Oriented Design
• OOD is divided into two major activities:
1) System design and
2) Object design.
• System design
 Creates the product architecture, defining a
series of “layers” that accomplish specific
system functions
 Identifying the classes that are encapsulated by
subsystems that reside at each layer.

3
Cont…
• In addition, system design considers the
specification of three components:
– The user interface,
– Data management functions, and
– Task management facilities.
• Object design focuses on the internal detail of
individual classes, defining attributes,
operations, and message detail.

4
Cont…
• A detailed specification of attribute data structures and a
procedural design of all operations are created during
object design.
• The visibility for all class attributes is defined and
interfaces between objects are elaborated to define the
details of a complete messaging model.
• System and object design in UML are extended to
consider the design of user interfaces, data management
with the system to be built, and task management for the
subsystems that have been specified.

5
Object Oriented Design

Process flow for OOD 6


Object Oriented Design
• Data management design establishes a set of
classes and collaborations that allow the system
(product) to manage persistent data (e.g., files and
databases).
• Task management design establishes the
infrastructure that organizes subsystems into tasks
and then manages task concurrency.

7
Object Oriented Design
• The unique nature of object-oriented design lies in its
ability to build upon four important software design
concepts:
• Abstraction,
• Information hiding,
• Functional independence, and
• Modularity.
• All design methods try for software that exhibits these
fundamental characteristics,
• But only OOD provides a mechanism that enables the
designer to achieve all four without complexity or
compromise.
8
Object Oriented Design
DESIGN FOR OBJECT-ORIENTED SYSTEMS
The four layers of the OO design pyramid are:
1) The subsystem layer contains a representation of each of the
subsystems that enable the software to achieve its customer-
defined requirements and to implement the technical
infrastructure that supports customer requirements.
2) The class and object layer contains the class hierarchies that
enable the system to be created using generalizations and
increasingly more targeted specializations.
This layer also contains representations of each object.

9
Cont…
3) The message layer contains the design details that
enable each object to communicate with its
collaborators.
This layer establishes the external and internal
interfaces for the system.
4) The responsibilities layer contains the data
structure and algorithmic design for all attributes and
operations for each object.

10
Object Oriented Design

Translating an OOA model into an OOD model 11


A) THE SYSTEM DESIGN PROCESS:
1) Partition the analysis model into subsystems.
2) Identify concurrency that is dictated by the problem.
3) Allocate subsystems to processors and tasks.
4) Develop a design for the user interface.
5) Choose a basic strategy for implementing data
management.
6) Identify global resources and the control
mechanisms required to access them.
7) Inter-subsystem Communication
8) Review and consider trade-offs.
12
THE SYSTEM DESIGN PROCESS: cont..
1) Partitioning the Analysis Model
• In OO system design, we partition the analysis model to
define cohesive collections of classes, relationships, and
behavior.
• These design elements are packaged as a subsystem.
• In general, all of the elements of a subsystem share some
property in common.
• They all may be involved in accomplishing the same
function; they may reside within the same product hardware,
or they may manage the same class of resources.
• Sub-systems are characterized by their responsibilities; that
is, a subsystem can be identified by the services that it
provides.
13
THE SYSTEM DESIGN PROCESS: cont..

When used in the OO system design context, a


service is a collection of operations that perform a
specific function
Example:-
• Managing word-processor files,
• Producing a three-dimensional rendering,
• Translating an analog video signal into a
compressed digital image).

14
THE SYSTEM DESIGN PROCESS: cont..
• As subsystems are defined (and designed), they should conform
to the following design criteria:
1) The subsystem should have a well-defined interface
through which all communication with the rest of the
system occurs.
2) With the exception of a small number of
“communication classes,” the classes within a subsystem
should collaborate only with other classes within the
subsystem.
3) The number of subsystems should be kept low.
4) A subsystem can be partitioned internally to help reduce
complexity.
• When two subsystems communicate with one another, they can
establish a client-server link or a peer-to-peer link. 15
THE SYSTEM DESIGN PROCESS: cont..

2) identifying Concurrency and Subsystem


Allocation
 The dynamic aspect of the object-behavior model
provides an indication of concurrency among classes
(or subsystems).
 If classes (or subsystems) are not active at the same
time, there is no need for concurrent processing.
 This means that the classes (or subsystems) can be
implemented on the same processor hardware.

16
Cont…
• On the other hand, if classes (or subsystems) must act
on events asynchronously and at the same time, they
are viewed as concurrent.
• When subsystems are concurrent, two allocation
options exist:
• Allocate each subsystem to an independent processor
or
• Allocate the subsystems to the same processor and
provide concurrency support through operating
system features.
17
THE SYSTEM DESIGN PROCESS: cont..
3) The Task Management Component
 The characteristics of a task are determined by
understanding how the task is initiated.
 Event-driven and clock-driven tasks are the most
commonly encountered.
 Both are activated by an interrupt, but Event-driven
receives an interrupt from some outside source (e.g.,
another processor, a sensor) while clock-driven is
governed by a system clock.
 In addition to the manner in which a task is initiated,
the priority and criticality of the task must also be
determined.
18
Cont…
• High-priority tasks must have immediate access to
system resources.
• High-criticality tasks must continue to operate even
if resource availability is reduced or the system is
operating in a degraded state.
• Once the characteristics of the task have been
determined, object attributes and operations
required to achieve coordination and communication
with other tasks are defined.

19
THE SYSTEM DESIGN PROCESS: cont..

4) The User Interface Component


 Although the user interface component is
implemented within the context of the problem
domain, the interface itself represents a critically
important subsystem for most modern applications.
 The OO analysis model contains usage scenarios
(called use-cases) and a description of the roles that
users play (called actors) as they interact with the
system.

20
Cont…
• These serve as input to the user interface design
process.
• Because a wide variety of user interface
development environments already exist, the design
of GUI elements is not necessary.
• Reusable classes (with appropriate attributes and
operations) already exist for windows, icons, mouse
operations, and a wide variety of other interaction
functions.

21
THE SYSTEM DESIGN PROCESS: cont..
5) The Data Management Component
Data management incorporates two distinct areas of concern:
1) The management of data that are critical to the application
itself
2) The creation of an infrastructure for storage and retrieval of
objects.
Within the system context, a database management system
is often used as a common data store for all subsystems.
The design of the data management component includes the
design of the attributes and operations required to manage
objects.

22
THE SYSTEM DESIGN PROCESS: cont..

6) The Resource Management Component


• A variety of different resources are available to an
OO system or product; and in many instances,
subsystems compete for these resources at the same
time.
• Global system resources can be external entities
(e.g., a disk drive, processor, or communication
line) or abstractions (e.g., a database, an object).
• Regardless of the nature of the resource, the
software engineer should design a control
mechanism for it.
23
THE SYSTEM DESIGN PROCESS: cont..

7) Inter-subsystem Communication
• Once each subsystem has been specified, it is
necessary to define the collaborations that exist
between the subsystems.
• The model that we use for object-to-object
collaboration can be extended to subsystems as a
whole.
• As we noted earlier in this chapter, communication can
occur by establishing a client/server link or a peer-to-
peer link.
• We must specify the contract that exists between
subsystems.
24
Object Oriented Design

A model of collaboration between subsystems


25
Object Oriented Design

• Abbreviated subsystem collaboration graph for Safe-Home


26
B) THE OBJECT DESIGN PROCESS
• OO system design might be viewed as the floor
plan of a house.
• The floor plan specifies the purpose of each room
and the architectural features that connect the rooms
to one another and to the outside environment.
• It is now time to provide the details that are
required to build each room.
• In the context of OOD, object design focuses on the
“rooms.”

27
THE OBJECT DESIGN PROCESS cont…….

• Object design is concerned with the detailed design


of the objects and their interactions.
• It is completed within the overall architecture
defined during system design and according to
agreed design guidelines and protocols.
• Object design is particularly concerned with the
1. Specification of attribute types,
2. How operations function, and
3. How objects are linked to other objects.
• Local data structures are defined (for attributes) and
algorithms (for operations) are designed.
28
THE OBJECT DESIGN PROCESS cont…….

1) Designing Algorithms and Data Structures


• A variety of representations contained in the analysis
model and the system design provide a specification
for all operations and attributes.
• An algorithm is created to implement the
specification for each operation.
• In many cases, the algorithm is a simple
computational or procedural sequence that can be
implemented as a self-contained software module.
• However, if the specification of the operation is
complex, it may be necessary to modularize the
operation.
29
THE OBJECT DESIGN PROCESS cont…….

• Data structures are designed concurrently with


algorithms.
• Since operations invariably manipulate the attributes of
a class, the design of the data structures that best reflect
the attributes will have a strong bearing on the
algorithmic design of the corresponding operations.
• Although many different types of operations exist, they
can generally be divided into three broad categories:
1) Operations that manipulate data in some way (e.g., adding,
deleting, reformatting, selecting),
2) Operations that perform a computation, and
3) Operations that monitor an object for the occurrence of a
controlling event.
30
THE OBJECT DESIGN PROCESS cont…….

2) Program Components and Interfaces


• An important aspect of software design quality is modularity;
that is, the specification of program components (modules) that
are combined to form a complete program.
• The object-oriented approach defines the object as a program
component that is itself linked to other components (e.g.,
private data, operations).
• But defining objects and operations is not enough.
• During design, we must also identify the interfaces between
objects and the overall structure (considered in an architectural
sense) of the objects.
• Although a program component is a design abstraction, it
should be represented in the context of the programming
language used for implementation. 31

You might also like