Lesson 2
Lesson 2
Object
Orientation and
Beyond
Object orientation (OO) is the most
dominant paradigm for programming and
software design, influencing how modern
software is developed. It introduces a
structured approach to designing software
by focusing on objects—instances of classes
that encapsulate both data and behavior
Object Orientation
Data abstraction involves defining a clear
separation between the definition of data
(what the data represents) and the operations
that can be performed on it (how the data is
used). In object orientation, this is realized
through object types (OT) and abstract data
types (ADT). In OO languages, data abstraction
is often realized through classes and
interfaces, which define the structure and
behavior of objects.
Data Abstraction
Data Abstraction
Object Types (OT) - These Abstract Data Types
are specific (ADT) - ADT is a well-defined
implementations of data interface for a set of
abstractions that consist of operations that can be
both an interface (defining performed on data,
operations) and a hidden independent of any
state. OT is less commonly particular implementation.
used than ADT but is closely The operations are
related. implemented in a class that
provides the functionality
defined by the ADT.
Object Types and Their
Importance
Object Construction: Objects in OO programming are instances
of classes, constructed using specific methods and operations
defined by their class or type. This involves procedural abstraction,
where the internal implementation details are hidden, and only the
interface is exposed
Dynamic Nature: Objects are dynamic entities, meaning they can
change state and behavior based on runtime conditions. This is a
significant feature of OO programming, allowing flexibility and
modularity
Interfaces in OO programming define a set of operations that can
be performed on objects, providing a contract that any
implementing class must follow. This allows for interchangeable
components and promotes polymorphism
Inheritance is a mechanism by which a new
class (subclass) inherits the properties and
behaviors of an existing class (superclass).
This promotes code reuse and hierarchical
classification
Inheritance
A plausible scenario of
class inheritance
Types of Inheritance
Implementation Interface Inheritance -
Inheritance - Involves Involves inheriting only
inheriting the actual code the interface, allowing the
from the superclass. subclass to provide its
own implementation of
the inherited methods.
Inheritance Benefits and
Code Reuse Drawbacks
- Complexity - Excessive
Inheritance allows or improper use of
subclasses to reuse code inheritance can lead to
from superclasses, complex and rigid class
reducing redundancy. hierarchies, making the
software harder to
maintain and extend.
Class and Object Interaction
Class
Encapsulation Polymorphism
Definitions
Classes are Encapsulation is Polymorphism
blueprints for the practice of allows objects of
objects, defining hiding the internal different classes
their structure state and to be treated as
(data) and requiring all objects of a
behavior interactions to common
(methods). A class occur through an superclass. This
can implement object's methods. enables one
multiple This ensures that interface to be
interfaces, which the object's state used for a general
allows for flexible remains consistent class of actions,
and modular and controlled promoting
design flexibility in the
Object
Orientation as a
Design Paradigm
Integration of Data and
Operations
Unlike procedural design, which separates data from
operations, OOD integrates these into objects. This
unification changes the way problems are modeled and
solved, leading to:
Modularity: Each object is a self-contained unit, making the
software easier to understand, modify, and maintain
Language Adaptations
Dynamic Nature of Objects
Unification of
Data and Benefits
Designed
Intelligence
Distributed
Complexity
Operations
Objects naturally Each object Complexity is
combine data with contributes to the spread across
the operations overall system's multiple objects
that act on them, intelligence by rather than
reflecting real- encapsulating concentrated in a
world entities. specific tasks or single function or
data procedure, making
systems easier to
manage
Software design is increasingly paradigm-
neutral, focusing on problem-solving and
system requirements rather than strict
adherence to a single paradigm. This shift
encourages more adaptive and effective
software design methodologies.