Object-Oriented Programming: Principles, Advantages & Development

Object-Oriented Programming (OOP)

A module is a group of components designed for a common purpose. These components may include types, variables, constants, procedures, functions, etc. A module encapsulates its components, allowing interface with other modules while exposing only necessary components (exported), hiding others. This is crucial for managing the complexity of modern software.

Software Complexity: Assembly language programs of past decades were hundreds of lines; today, high-level languages have hundreds of thousands or millions. Large projects involve teams of developers working on hundreds or thousands of independent modules. Effective communication and coordination are essential.

Object-Oriented Systems: Programming is done using extensions of traditional languages (Object Pascal, C++) or pure OO languages (Smalltalk, Eiffel). OOP accommodates heterogeneous data structures and complex types, allowing new types to be added without modifying existing code.

Software Quality Factors

  • Efficiency: Effective resource utilization.
  • Portability: Ease of transferring software to different systems.
  • Verifiability: Support for validation and testing.
  • Integrity: Protection of components from unauthorized access.
  • Ease of Use: User-friendly interface.
  • Correctness: Accurate execution of defined tasks.
  • Robustness: Functionality even in abnormal situations.
  • Extensibility: Adaptability to specification changes.
  • Reusability: Components used in new applications.
  • Supportability: Integration with other products.

Foundations of Object-Oriented Programming

OOP’s development is driven by the need for code reuse and improved management of complexity. Key elements include:

  • Encapsulation: Hiding internal details of an object.
  • Modularity: Dividing an application into independent modules.
  • Hierarchy: Ordering of abstractions (generalization/specialization and aggregation).
  • Polymorphism: Ability of an entity to take many forms.

Key OOP Concepts

Abstraction

An abstraction focuses on the external view of an object, separating essential behavior from implementation. It’s an abstract description of a group of objects.

Encapsulation

This ensures that an object’s internal state is hidden. Object A doesn’t know the internals of object B, and vice versa. It’s also known as information hiding.

Modularity

This allows an application to be divided into smaller, independent modules. Modules can be compiled separately but connect with others.

Hierarchy

This allows ordering of abstractions. Important hierarchies include generalization/specialization and aggregation.

Polymorphism

This is the ability of an entity to take many forms. It requires dynamic binding and is only possible in object-oriented languages.

Modules and Packages

A module is a program unit implemented as a separate entity. A well-designed module has a unique purpose and a narrow interface. Packages are groups of declared components (types, constants, variables, procedures, functions, sub-packages).

Abstract Types

An abstract type is defined by a group of operations (constants, functions, procedures). The set of values is defined indirectly by applying operations to constants.

Classes and Objects

A class is a blueprint for creating objects. Objects are instances of a class, combining data and operations. They have state, behavior, and identity.

Generics

Generics provide abstraction over statements, allowing for type parameters.

Programming Paradigms

Objects

An object has state (static and dynamic properties), behavior (actions and reactions), and identity (distinguishing it from other objects).

Messages

Objects communicate through messages (operation names and arguments). The sender doesn’t specify how the operation is performed.

Abstraction (Further Explanation)

Abstraction focuses on the external view, separating essential behavior from implementation. Abstraction and encapsulation are complementary.

Encapsulation (Further Explanation)

Encapsulation hides internal details not contributing to essential characteristics. It allows changes to be made reliably with limited effort.

Classes

A class is a generic specification for objects sharing the same behavior. Objects of the same class differ in identity and data.

Inheritance

Inheritance allows a class to inherit structure and behavior from another class (superclass). Subclasses can add or redefine behavior. This promotes code reuse.

Relationships Between Classes

  • Inheritance: Hierarchical relationship.
  • Aggregation:“Part-whol” relationship.
  • Association: Objects cooperating through services.

Polymorphism (Further Explanation)

Polymorphism allows different objects to respond to the same message in their own way. Dynamic binding links the message to the receiver at runtime.

Development Cycle

Object-oriented development uses iterative cycles (like the Boehm spiral) rather than the sequential waterfall model. More time is spent on design to ensure reusability and maintainability.

Objectives of Object-Oriented Introduction

  • Increased productivity through reusability.
  • Improved quality through robust, reusable components.
  • Improved maintainability through flexible development cycles.

Advantages of Object-Oriented Programming

  • High modularity
  • High extensibility
  • High reusability
  • Simplicity of design
  • Easy modifiability
  • Better understanding of applications
  • Flexible development cycles
  • Consistency between analysis, design, and programming

Problems with Object-Oriented Programming

  • Lack of consensus on methodologies
  • Need for training and cultural change
  • Need for a methodology to manage reusability