Overview of the Object-Oriented Paradigm



index
Disabled back button Next Section
printable version




Section 0: Module Objectives or Competencies
Course Objective or Competency Module Objectives or Competency
The student will be able to assess and apply Object-Oriented analysis and design methods like use cases to express user requirements, UML modeling, and other OO approaches. The student will review his or her understanding of basic OO concepts.


Section 1: Concepts of the Object-Oriented Paradigm

The fundamental idea behind object-oriented design is to combine both data and the functions that operate on that data into a single unit called an object.


Quick Overview

Video: Classes and Objects


Classes

Although we refer to this as the object-oriented paradigm, something called a class provides the basic building block.

Example: consider a student.


Objects

An object is a specific, and therefore more detailed, instance of a class.

Let's go back to our student example.


Instantiation

Classes must be defined by the designer before objects can be created from the class.

Just as an instance of a primitive data type is called a variable, an instance of a class is called an object.

There may be many objects that belong to a class, just as there may be many variables of a primitive data type.

Placing data and functions together into a single entity is the central idea of the object-oriented approach.



Section 2: Terminology

The OO approach is generally characterized by four distinguishing features – abstraction, polymorphism, inheritance, and encapsulation (sometimes referred to collectively as A-PIE).

Why aren't they listed in A-PIE order? The A-PIE order is used to help you remember the features, but in design you will encounter them in the order presented in the list.


Quick Overview

Video: Basics of OO


Abstraction

Abstraction requires the designer to ignore irrelevant features, properties, or functions while emphasizing those that are relevant to the given project.

Consider again our student example:


Encapsulation

Encapsulation is the act of grouping into a single object both data and the operations that affect that data.

Example: David the student requests that his major be changed to INFO.  The enrollment system sends a "Change Major" message to the David object (class Student). The David object has a behavior (also called a "method") called setMajor, that reacts to this message by changing its own object's 'major' attribute to 'INFO'.

Encapsulation is significant because


Inheritance

Inheritance is the process of creating new classes (derived classes) from existing classes (base classes).

A derived class can be created in such a way that it will inherit all of the attributes and behaviors of the base class.

Example: Person and Student class

A derived class shares all the characteristics of a base class, but can add new characteristics as well. A derived class is not limited to the inherited attributes and behaviors.

Inheritance reduces development labor by reusing existing objects.


Polymorphism

Polymorphism refers to the ability to perform the same operation on different types of objects, each one implementing that operation in a way appropriate to them.

Polymorphism enables a message to have different effects depending on exactly what class of object receives the message.

Example: setAddress in the Person and Student classes

Thus, when multiple classes inherit both attributes and behaviors, there can be cases where the behavior of a derived class might be different from that of its base class or its sibling derived classes.

The "Rachel" student object can be directed to change its address without knowing if Rachel is an object that belongs to the Student or the Person class.

Here is another example if polymorphism isn't clear.


Related concepts


Instances

An object has the same relationship to a class that a variable has to a data type.

An object is said to be an instance of a class.


Methods

Methods are member functions that are included within a class in order to implement a specific behavior that objects of that class are capable of performing.

In order for an object to perform an action, one of its methods must be invoked.

If a class does not include a method for a particular action, then objects of that class cannot perform that action.


Extensibility

Extensibility refers to the creation of new data types from existing data types.

Inheritance is a form of extensibility.


Reusability

Once a class has been written, created, and debugged, it can be used in multiple systems.

Reusability can be utilized in conjunction with inheritance to create derived classes from a base class.


Information Hiding

Information hiding is the technique of concealing implementation details within the objects themselves, while the interface remains visible.

Data is concealed within a class, so that it cannot be accessed mistakenly by functions outside the class.



Section 3: Systems of Objects

The following is adapted from Basic Object-Oriented Concepts.

In constructing object-oriented models and object-oriented applications, one quickly finds that single classes and single instances are not enough.

Systems of interacting objects are collections of items that support a single, large, coherent, object-oriented concept, and in which there must be a direct or indirect physical connection between any two arbitrary objects within the collection.

Systems of interacting objects resemble applications.


Class Interactions

So a software system is often made of various classes.

Once the various classes have been specified, the designer has to determine how those classes interact with each other.

Here is an example UML diagram from this old assignment:

UML Diagram

UML Diagram



Section 4: Summary

One benefit of the object-oriented approach is the close correspondence between the real-world things being modeled by the system and the objects in the system.

This makes it easy to conceptualize a problem. You figure out what parts of the system can be most usefully represented as objects, and then put all the data and methods connected with that object into the class specification.

In some situations it may not be obvious what parts of a real-life situation should be made into objects because there are no hard and fast rules. Often you proceed by trial and error. You break the problem into objects in one way and write trial class specifiers for these objects. If the classes seem to match reality in a useful way, you continue. If they don't, you start over, selecting different entities to be classes. The more experience you have with OOP, the easier it will be to break a system into classes.