<< Chapter < Page Chapter >> Page >
An overview of how object oriented programming is different from procedural or modular structured programming.

Discussion

"In procedural programming, the programmer constructs procedures (or functions, as they are called in C++). The procedures are collections of programming statements that perform a specific task. The procedures each contain their own variables and commonly share variables with other procedures. Procedural programming is centered on the procedure or function." Tony Gaddis, Judy Walters and Godfrey Muganda, Starting Out with C++ Early Objects Sixth Edition (United States of America: Pearson – Addison Wesley, 2008) 22. For decades (1950s to through the 1980s) most programming was taught as procedural programming . Coupled with the imposition of using standardized control structures in the late 1960s, we have what is typically called modular structured programming .

Another, equally valid approach to programming is object-oriented programming or OOP. It was introduced in the mid 1980s and was widely accepted as a programming approach by the early 1990s. The first languages to introduce OOP to the masses were C++ and Java. Shortly after their introduction, there were American National Standards Institute (ANSI) standards established for those languages. Today, C++ and Java are widely used.

"The primary differences between the two approaches is their use of data. In a procedural program, the design centers around the rules or procedures for processing the data. The procedures, implemented as functions in C++, are the focus of the design. The data objects are passed to the functions as parameters. The key question is how the functions will transform the data they receive for either storage or further processing. Procedural programming has been the mainstay of computer science since its beginning and is still heavily used today.

In an object-oriented program, abbreviated OOP, the design centers around objects that contain (encapsulate) the data and the necessary functions to process the data. In OOP, the objects own the functions that process the data." Behrouz A. Forouzan and Richard F. Gilberg, Computer Science A Structured Approach using C++ Second Edition (United States of America: Thompson – Brooks/Cole, 2004) 156.

"Object-oriented programming … is centered on the object. An object is a programming element that contains data and the procedures that operate on the data. The objects contain, within themselves, both the information and the ability to manipulate the information." Tony Gaddis, Judy Walters and Godfrey Muganda, Starting Out with C++ Early Objects Sixth Edition (United States of America: Pearson – Addison Wesley, 2008) 22.

To help complicate the picture, the C++ programming language can be used (and is used) to write either a procedural program (modular structured program) or an object-oriented program. Some items used by those writing procedural programs in C++ are in fact objects. Examples include:

  1. Standard input and output items of: cout and cin; example: cout.setf(ios::fixed)
  2. Strings; calculating the length with: identifier_name.length()
  3. File input/output; example: inData.open(filespec, ios::in)

Objects are implemented with a "class" data type; which is a complex or derived data type. Implementation details will not be presented in the module.

Transition

Many students will learn modular structured programming before learning object-oriented programming. The common way of teaching programming fundamentals is to cover them or divide them into three courses, usually covered in this order:

  1. Modular structured
  2. Object-oriented
  3. Data structures

The following items learned in modular structured programming flow into the learning of object-oriented programming:

  1. The standard and complex data types are the same
  2. The operators are the same, thus data manipulation is the same
  3. The control structures are the same
  4. Concepts of documentation and making code readable are the same
  5. The use of test data to verify logical thinking and program results is similar

Definitions

procedural programming
Aka modular structured programming.
object oriented
A programming approach that encapsulates data with functions.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals - a modular structured approach using c++. OpenStax CNX. Jan 10, 2013 Download for free at http://cnx.org/content/col10621/1.22
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals - a modular structured approach using c++' conversation and receive update notifications?

Ask