Here 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:
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.