Difference Between OOP and Procedural Programming Language (Part 1)

Introduction

In this paper I will discuss the differences between procedural programming hereafter referred to as PROCEDURAL PROGRAMMING and object oriented programming hereafter referred to  as OBJECT-ORIENTED PROGRAMMING. I will discuss some of the benefits of using both languages as well as some of the difficulties in using each.

I will also discuss some important concepts that must be understood in using each language and how they compare to each other. After reviewing concepts I will discuss the design and development process for each language, followed by the advantages and disadvantages of each programming language.

Finally I will discuss the reusability and maintainability of each language, and how they differ from each other.

Object-Oriented Programming Languages

OBJECT-ORIENTED PROGRAMMING is a programming language that uses classes and objects to create models based on the real world environment. An OBJECT-ORIENTED PROGRAMMING application may use a collection of objects which will pass messages when called upon to request a specific service or information. Objects are able to pass, receive messages or process information in the form of data.

One reason to use OBJECT-ORIENTED PROGRAMMING is because it makes it easy to maintain and modify existing code as new objects are created inheriting characteristics from existing ones (SEH, 2013). This cuts down the development time considerably and makes adjusting the program much simpler.

Another reason to use OBJECT-ORIENTED PROGRAMMING is the ease of development and ability for other developers to understand the program after development. Well commented objects and classes can tell a developer the process that the developer of the program was trying to follow. It can also make additions to the program much easier for the new developer.

The last reason to use OBJECT-ORIENTED PROGRAMMING that I will mention here is the efficiency of the language. Many programming languages using OBJECT-ORIENTED PROGRAMMING will dump or destroy unused objects or classes freeing up system memory. By doing this the system can run the program faster and more effectively.

Procedural Programming Languages

PROCEDURAL PROGRAMMING which at times has been referred to as inline programming takes a more top down approach to programming. OBJECT-ORIENTED PROGRAMMING uses classes and objects, PROCEDURAL PROGRAMMING takes on applications by solving problems from the top of the code down to the bottom.

This happens when a program starts with a problem and then breaks that problem down into smaller sub-problems or sub-procedures. These sub-procedures are continually broken down in the process called functional decomposition until the sub-procedure is simple enough to be solved.

The issue that is obvious in PROCEDURAL PROGRAMMING is that if a edit is needed to the program, the developer must edit every line of code that corresponds to the original change in the code. An example would be if at the beginning of a program a variable was set to equal the value of 1. If other sub-procedures of the program rely on that variable equaling 1 to function properly they will also need to be edited. As more and more changes may be needed to the code, it becomes increasingly difficult to locate and edit all related elements in the program.

Simple comparison between OBJECT-ORIENTED PROGRAMMING and PROCEDURAL PROGRAMMING

A simple way to compare both programming methods is to think of OBJECT-ORIENTED PROGRAMMING as  learn to read picture book. As children see pictures of simple objects like a house or picture they know that throughout the book when they see a picture of the house it represents the word house. The children can then read through the book as words are substituted throughout the story with pictures.

In OBJECT-ORIENTED PROGRAMMING the classes could represent the pictures in the learn to read books. A house could represent a class and anything the developer wants to have included to describe that house like the color, size, number of bathrooms etc.

In PROCEDURAL PROGRAMMING the learn to read book would be words on the page without pictures to help guide the young learner through the book. If the story was changed in the beginning of the book it could disrupt or make the story later on in the book not make any sense. Although learning to read the book would make programming with PROCEDURAL PROGRAMMING simple, it would make it difficult for other readers in the case of the book or programmers in the case of PROCEDURAL PROGRAMMING to add to the story.

PROCEDURAL PROGRAMMING also uses different methods throughout the code than OBJECT-ORIENTED PROGRAMMING. As an example OBJECT-ORIENTED PROGRAMMING uses methods where PROCEDURAL PROGRAMMING uses procedures. OBJECT-ORIENTED PROGRAMMING uses objects where PROCEDURAL PROGRAMMING uses records. OBJECT-ORIENTED PROGRAMMING uses classes where PROCEDURAL PROGRAMMING uses modules and OBJECT-ORIENTED PROGRAMMING uses messages where PROCEDURAL PROGRAMMING uses procedure calls . In addition OBJECT-ORIENTED PROGRAMMING uses data fields where PROCEDURAL PROGRAMMING uses procedures.  A chart has been provided below to illustrate the differences between the two:

Procedural

Object-oriented

procedure method
record object
module class
procedure call message

(Wikipedia, 2013)

Beyond the major differences listed in the chart there are also some detailed differences that were not listed. As an example OBJECT-ORIENTED PROGRAMMING classes have data fields that are a part of that class. If there was a class called dog some of the data fields might be eye color, breed etc. In PROCEDURAL PROGRAMMING the data is not the focus and would not be introduced until needed in the program. With PROCEDURAL PROGRAMMING the program would wait until the flow of the program got to the data vs. OBJECT-ORIENTED PROGRAMMING where the data would be stored when the class was loaded.

Important design concepts

The design process for each method of programming differs in many ways. With OBJECT-ORIENTED PROGRAMMING, designs can be reused and recycled throughout the program where PROCEDURAL PROGRAMMING is usually not able to do this. Additionally planning out the process of the design is much different with PROCEDURAL PROGRAMMING than it is with OBJECT-ORIENTED PROGRAMMING.

First we will look at important design processes for OBJECT-ORIENTED PROGRAMMING and then PROCEDURAL PROGRAMMING. Although I may not include every element used in each design process, I will cover major design elements to help illustrate the differences between the two methods of programming.

OBJECT-ORIENTED PROGRAMMING Design Concepts

When developing with OBJECT-ORIENTED PROGRAMMING a developer does not simply sit down and begin to write out code on a page that comes to their mind. The application must be planned out in a series of steps and diagrams.

When first developing a new program a programmer must determine what the program must do and how it will function. If the program is a grading system the developer might need to know who will be using the system, what access they will have, if they need to add, edit or delete the data in the system, what data will actually be stored etc. Planning out the system can be a very difficult and time consuming task, but without proper planning the application could have difficulty functioning properly.

When planning out the design of a OBJECT-ORIENTED PROGRAMMING a developer will usually start with a list of classes that need to be included in the program. For a grading system there might be classes for users, grades, schools etc depending on what data was being stored in the system and how the data relates to each other.

Once a developer has an idea of what classes should be used in the application they will usually draw out the system using diagrams such as the class diagram to illustrate the system. During this process of illustration the designer is able to make edits to the system and check for errors in functionality. As the developer moves through the diagram including functions and methods it makes the application make more visual sense and often makes clearing up any issues easier.

Developers will often break down the program into activity and other diagrams to illustrate functions of the program in greater detail. These diagrams make developing the application or program much easier when it comes time for actual coding.

Once the planning has finished and the developer has the development plans ready usually in the form of diagrams, it is finally time to actually begin coding. The process of coding the application is much simpler once the diagrams are in place simply because it is like building a house from blue-prints. As long as the developer knows how to follow the plans and build according to them, the building of the application stays manageable.

PROCEDURAL PROGRAMMING Design Concepts

When developing with PROCEDURAL PROGRAMMING a developer may take a much different approach to designing an application. PROCEDURAL PROGRAMMING takes a more top down approach to writing an application and while a developer who uses OBJECT-ORIENTED PROGRAMMING to create applications would think of planning out the program with re-usable classes, a developer who uses PROCEDURAL PROGRAMMING might plan out the program without the idea of recycling code.

Planning is still involved in PROCEDURAL PROGRAMMING but it takes a much more literal approach. In the case of a grading system, instead of thinking about what classes or objects will need to be used with functions and methods, a PROCEDURAL PROGRAMMING programmer may think in terms of how the program should execute as the code is executed.

PROCEDURAL PROGRAMMING applications are planned out more like a story format than a diagram format. A developer would still need to list out who is using the program and what they will need to access, but the code is not reused in the same was as OBJECT-ORIENTED PROGRAMMING. By coding in this way it makes the development process much simpler but also more time consuming.

For example a PROCEDURAL PROGRAMMING developer who is building the grade system might first create a form where a user can register to access the system. The data that is captured by the form would then need to be verified with some kind of method and then stored into a database of some kind. After the user submitted the form and the data was verified, a confirmation would need to be displayed to the user letting them know the status of their registration.

This entire process in PROCEDURAL PROGRAMMING would be coded directly into the application and would only be useful for the process of registering the user. Other processes such as logging on and logging off would all be separate processes that would need to be coded into the application.

Unlike OBJECT-ORIENTED PROGRAMMING where objects and classes can be referenced throughout the program, problems being solved in PROCEDURAL PROGRAMMING would need to be individually addressed as the program is executed.

Summary of important design concepts

When designing in OBJECT-ORIENTED PROGRAMMING or PROCEDURAL PROGRAMMING languages, the developer will need to have a plan for the program before actually writing any code. PROCEDURAL PROGRAMMING can be a tempting solution for many developers because it means they can usually jump into coding quicker, but it can be a time consuming solution later when changes to the code are needed.

Additionally the up-front planning that is involved in OBJECT-ORIENTED PROGRAMMING can pay off in the long run when changes or additions are needed and during the debugging process where errors can be traced more directly to the class or object it is associated with.

Question about "Difference Between OOP and Procedural Programming Language (Part 1)"?