A Comparative Analysis of Structured and Object-Oriented Programming Methods
* Corresponding Author: Asagba, Prince Oghenekaro
44
Data Abstraction
Data abstraction is a methodology that enables us to
isolate how a compound data object is used from the
details of how it is constructed from more primitive
data objects (Ryan, 2000). Data abstraction is the
enforcement of a clear separation between the
abstract properties of a
data
type
and the concrete
details of its implementation. Data Abstraction is
simplifying complex reality by modeling classes
appropriate to the problem, and working at the most
appropriate level of inheritance for a given aspect of
the problem. Abstraction is also achieved through
Composition
. For example, a class Car would be
made up of an Engine, Gearbox, Steering objects, and
many more components. To build the Car class, one
does not need to know how the different components
work internally, but only how to
interface
with them,
that is, send messages to them, receive messages from
them, and perhaps make the different objects
composing the class interact with each other
(Wikipedia, 2008).
Encapsulation
Encapsulation is the ability to package codes and data
together in a place and hide (or prevent) that data
from external contact thereby forcing anyone who
wants to access it to pass through the associated code.
Structured programming encourages code everywhere
to deal directly with data structures.
Inheritance
This is the ability of an existing class to create new
classes. Thus existing class is referred to as a base
class and the newly created classes are called derived
class. The derived class inherits all the features
inherent in the base class. Inheritance is perhaps one
of the most powerful features of object-oriented
programming paradigm. Inheritance can support
program (or software) reuse, reliability, and
modification of the base class (Asagba, 2002).
Inheritance is a powerful programming tool and it
supports reusable component. Inheritance establishes
a parent-child dependency relationship between
objects in a class. The inheritance graph is a tree. A
single inheritance is a case when each derived class
can inherit from only one base class, whereas a
multiple inheritance is a case in which a class may
inherit from two or more base classes. Newer object-
oriented languages such as Java and C++ provide
multiple inheritances. In a language with multiple
inheritances, its graphs can be acyclic instead of a
tree. Multiple inheritances can be useful but its
approach can be complex. One issue is that methods
may be inherited in more than one way. For instance,
a method from class A is inherited by class D in two
separate ways. Fig. 3 shows multiple inheritances
graph.
Dostları ilə paylaş: