Object-Oriented DesignThere is great interest in a conceptual approach to
programming and systems analysis called object-oriented analysis. This approach to design is tied very closely
to programming: software becomes a collection of discrete objects that
incorporate data structure and behaviour. An object is a representation of some
real-world thing and a number of
specific instances of that thing. For
example, we could define a Ford Explorer as an object. Objects encapsulate attributes and services;
this Explorer has four doors and four-wheel drive. All objects have an identity and can be
distinguished from one another. A class describes a group of objects with similar
properties, common behaviour, and common relationships with other objects. The Explorer is a member of the Vehicles
class. The grouping of objects into classes makes it easier to work with
abstractions. The designer can think about
the system at the level of the class without having to bother with individual
object in the class. There are methods
or procedures associated with each class. They apply to the objects in the
class and change some attribute. The
same method may apply to different classes, but it may take on different forms
in different classes. This characteristic of a method applying across classes,
changing its implementation to match the class, is called polymorphism. A link connects different object instances, for example,
Mary Smith (an object) works for (a link) the Widget Company (an object). Links with common characteristics are grouped
into an association. Based on what we
have seen in past chapters, it may help to know that links and associations are
often implemented as pointers between the objects and classes. Objects communicate by sending messages. As a result, one object cannot directly
access the object in another class, which means that objects are encapsulated
or protected from damage from other objects.
The message generally results in the execution of some method of processing
that is stored with the object.
Different authors describe this processing as done through methods,
procedures, or services. To build an object-oriented model, you identify the classes
and objects in the problem domain. Class diagrams contain classes and show
their relationships, while object diagrams show how objects send and receive
messages. Over time, one builds class
libraries: an objective of this approach is to reuse software. For example, a class and its objects for an
inventory system might also be used in a production control system. Reuse is intended to reduce the amount of
time spent and cost of developing applications. Programmers implement
object-oriented systems with languages like C++ (C enhanced with features to
support object-oriented programming) or Smalltalk, one of the first object
oriented languages. As an example, assume you are to develop a vehicle
registration system. The object of
interest is a vehicle. There are many instances of vehicles (cars,
trucks), so an object tells us something
about a class of real-world things.
Instances of vehicles have different attributes (wheels, engines). The figure which follows shows a
classification structure for vehicles.
It shows that cars are one type of vehicle. We are interested in land
vehicles with internal combustion engines.
(We have eliminated the class of electric powered vehicles with the
following attributes: four wheels, door, and a body. Cars can be off-road or
on-road. An off-road car has four-wheel
drive and high ground clearance, and so on. A very significant concept in object-oriented analysis is
inheritance. Each instance of an object
inherits the properties of its class. An
instance of an on-road car a Ford station wagon, inherits all attributes above
it in the hierarchy. It is a land vehicle with an internal combustion engine
and has four wheels, doors, a body, regular tyres, and normal ground clearance. An important characteristic of object oriented analysis is
communications through messages among different objects. These messages may be in the form of services
that An object classification with inheritance Performed for the objects. One example of a service is to
register a vehicle and issue license plates.
Repairing a vehicle is another kind of service. The message triggers a
method or routine stored with the object to change some attribute of the
object, for example, a message from a mechanic object might say the Ford wagon
attribute “status” should be changed from “broken” to “in service”. |