12-03-2012, 03:30 PM
Object-oriented Design
[attachment=18224]
Object-oriented design is a design strategy where system designers think in terms of
‘things’ instead of operations or functions. The executing system is made up of
interacting objects that maintain their own local state and provide operations on that
state information (Figure 12.1). They hide information about the representation of
the state and hence limit access to it. An object-oriented design process involves
designing the object classes and the relationships between these classes. When the
design is realised as an executing program, the required objects are created
dynamically using the class definitions.
Object-oriented design is part of object-oriented development where an
object-oriented strategy is used throughout the development process:
· Object-oriented analysis is concerned with developing an object-oriented model
of the application domain. The identified objects reflect entities and operations
that are associated with the problem to be solved.
· Object-oriented design is concerned with developing an object-oriented model of
a software system to implement the identified requirements. The objects in an
object-oriented design are related to the solution to the problem that is being
solved. There may be close relationships between some problem objects and
some solution objects but the designer inevitably has to add new objects and to
transform problem objects to implement the solution.
· Object-oriented programming is concerned with realising a software design
using an object-oriented programming language. An object-oriented
programming language, such as Java, supports the direct implementation of
objects and provides facilities to define object classes.
Objects and object classes
The terms ‘object’ and ‘object-oriented’ are now widely used. They are applied to
different types of entity, design methods, systems and programming languages.
However, there is a general acceptance that an object is an encapsulation of
information and this is reflected in my definition of an object and an object class:
An object is an entity that 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.
Objects are created according to an object class definition. An object class
definition serves as a template for creating objects. It includes declarations of
all the attributes and operations which should be associated with an object of
that class.
The notation that I use here for object classes is that defined in the UML. An
object class is represented as a named rectangle with two sections. The object
attributes are listed in the top section. The operations that are associated with the
object are set out in the bottom section. Figure 12.2 illustrates this notation using
an object class which models an employee in an organisation. In the UML, the
term ‘operation’ is the specification of an action; the term ‘method’ is used to refer
to the implementation of the operation.
Concurrent objects
Conceptually, an object requests a service from another object by sending a ‘service
request’ message to that object. There is no requirement for serial execution where
one object waits for completion of a requested service. Consequently, the general
model of object interaction allows objects to execute concurrently as parallel
processes. These objects may execute on the same computer or as distributed
objects on different machines.
In practice, most object-oriented programming languages have as their
default a serial execution model where requests for object services are implemented
in the same way as function calls. Therefore, when an object called theList is
created from a normal object class, you write in Java:
theList.append (17)
This calls the append method associated with theList object to add the
element 17 to theList and execution of the calling object is suspended until the
append operation has been completed. However, Java includes a very simple
mechanism (threads) that lets you create objects that execute concurrently. It is
therefore easy to take an object-oriented design and produce an implementation
where the objects are concurrent processes.
There are two kinds of concurrent object implementation:
An object-oriented design process
In this section, I illustrate the process of object-oriented design by developing an
example design for the control software that is embedded in an automated weather
station. As I discussed in the introduction, there are several methods of objectoriented
design with no definitive ‘best’ method or design process. The process that
I cover here is a general one that incorporates activities that are common to most
OOD processes. In this respect, it is comparable to the proposed UML process
(Rumbaugh, Jacobson et al., 1999) but I have significantly simplified this process
for presentation here.