Object-Oriented Programming vs. Procedural Programming
Table of Contents
- Programming Paradigms
- Procedural Programming
- Object-Oriented Programming
- Key Differences
- OOP Most Popular
- Lesson Summary
- Two Types of Programming Paradigms
- Learning Outcomes
Programming is a creative process carried out by programmers to instruct a computer on how to do a task. A program is a set of instructions that tells a computer what to do in order to come up with a solution to a particular problem. There are a number of alternative approaches to the programming process, referred to as programming paradigms. Different paradigms represent fundamentally different approaches to building solutions to specific types of problems using programming. Most programming languages fall under one paradigm, but some languages have elements of multiple paradigms. Two of the most important programming paradigms are the procedural paradigm and the object-oriented paradigm. Let's look at each of these in a bit more detail.
To unlock this lesson you must be a Study.com Member.
Create your account
Procedural programming uses a list of instructions to tell the computer what to do step-by-step. Procedural programming relies on - you guessed it - procedures, also known as routines or subroutines. A procedure contains a series of computational steps to be carried out. Procedural programming is also referred to as imperative programming. Procedural programming languages are also known as top-down languages.
Procedural programming is intuitive in the sense that it is very similar to how you would expect a program to work. If you want a computer to do something, you should provide step-by-step instructions on how to do it. It is, therefore, no surprise that most of the early programming languages are all procedural. Examples of procedural languages include Fortran, COBOL and C, which have been around since the 1960s and 70s.
To unlock this lesson you must be a Study.com Member.
Create your account
Object-oriented programming, or OOP, is an approach to problem-solving where all computations are carried out using objects. An object is a component of a program that knows how to perform certain actions and how to interact with other elements of the program. Objects are the basic units of object-oriented programming. A simple example of an object would be a person. Logically, you would expect a person to have a name. This would be considered a property of the person. You would also expect a person to be able to do something, such as walking. This would be considered a method of the person.
A method in object-oriented programming is like a procedure in procedural programming. The key difference here is that the method is part of an object. In object-oriented programming, you organize your code by creating objects, and then you can give those objects properties and you can make them do certain things.
A key aspect of object-oriented programming is the use of classes. A class is a blueprint of an object. You can think of a class as a concept and the object as the embodiment of that concept. So, let's say you want to use a person in your program. You want to be able to describe the person and have the person do something. A class called 'person' would provide a blueprint for what a person looks like and what a person can do. Examples of object-oriented languages include C#, Java, Perl and Python.
To unlock this lesson you must be a Study.com Member.
Create your account
One of the most important characteristics of procedural programming is that it relies on procedures that operate on data - these are two separate concepts. In object-oriented programming, these two concepts are bundled into objects. This makes it possible to create more complicated behavior with less code. The use of objects also makes it possible to reuse code. Once you have created an object with more complex behavior, you can use it anywhere in your code.
Let's look at a simple example of this. You want to write a program that plays a song. Your band playing the song will have four members, and you start off by giving each of them a name:
myband = ('John,' 'Paul,' 'George,' 'Ringo')
Now that you have your band, it's time to pick the song:
mysong = 'Yellow Submarine'
Now you want your band to play the song, so you need two more things. First, you need to have the lyrics and the notes of the song. Second, each band member needs to know what to do: perform vocals, play a particular instrument or both. We'll just consider the first requirement here.
In procedural programming, you will need to include all the text and notes in the program so the band members can play it. However, you want to have another band play the song in another program. In procedural programming, you could copy and paste the code into another program so there is no need to manually type the same text again. However, why not save the text into a separate file and every time your band - or any band for that matter - wants to play that song, you simply call up the file. That way, your code for the song itself never needs to get duplicated.
This is exactly what object-oriented programming does. In technical terms, you would use a class called 'song' to create an object, 'Yellow Submarine.' This object has a number of properties, including lyrics and music notes. The class describes how to organize lyrics and music notes so it can be read by your band members. Other songs will have a similar organization, but with different lyrics and music notes. When you write your program for your band to play a song, you would call the object 'Yellow Submarine' so your band members have access to the lyrics and music notes.
In object-oriented programming, you still have to write out the lyrics and music notes of the song, but only once, and then any band can use the lyrics and music at any time. From now on, every other program can call the same object and play the song. And, other songs will be organized in a similar manner, so one band can play any song without having to change your code very much.
To unlock this lesson you must be a Study.com Member.
Create your account
Object-oriented programming has become the dominant programming paradigm in today's software development. Most of the newer programming languages that have been developed over the past 10 to 20 years are object-oriented. However, this does not mean that the other paradigms have gone away, and procedural programming languages are still widely used.
Some languages combine elements of both paradigms. For example, the widely used language C++ was derived from the language C, which is a procedural language. Object-oriented components were added to C to become C++, which is therefore both a procedural and object-oriented language.
To unlock this lesson you must be a Study.com Member.
Create your account
Different programming paradigms represent fundamentally different approaches to building solutions to specific types of problems. Two of the most important programming paradigms are procedural programming and object-oriented programming. Procedural programming uses a very detailed list of instructions to tell the computer what to do step-by-step. In object-oriented programming, you organize your code by creating objects, and then you can give those objects properties and you can make them do certain things. Object-oriented programming has become the dominant programming paradigm in today's software development, but procedural programming languages are still widely used.
To unlock this lesson you must be a Study.com Member.
Create your account
Procedural Programming | Object-Oriented Programming |
---|---|
*List of instructions telling the computer what to do step-by-step *Relies on routines and sub-routines *Most of the first computer programming languages are procedural |
*Approach to problem-solving where all computations are carried out using objects *Code is organized by creating objects, and then giving those objects properties and making them do certain things |
To unlock this lesson you must be a Study.com Member.
Create your account
After you have finished with this lesson, you should be able to:
- Define programming paradigms
- Explain how both procedural and object-oriented programming work
- Discuss the differences in procedural programming and object-oriented programming
- Identify the most popular programming paradigm used today
To unlock this lesson you must be a Study.com Member.
Create your account
Object-Oriented and Procedural Programming Word Search Activity
This activity will help you assess your knowledge of two of the most important approaches in programming.
Guidelines
For this activity, print this page on a blank piece of paper. Search and highlight the word that will complete each of the given clues. Afterward, neatly write them on the appropriate blank space in the clues.
Clues
- OOP is known as a problem-solving approach in which data computation is carried out in terms of _____.
- _____ is extensible templates for creating objects, providing initial values for state and implementations of its behavior.
- The focus of procedural programming is to break down a programming task into a collection _____.
- Most of the early programming languages, such as _____, are all procedural.
- Procedural programming is a type of _____ programming in which the program is built from one or more procedures.
- The process of developing and implementing various sets of instructions to enable a _____ to do a certain task.
- _____ are procedures associated with an object class and defines the action that it is able to perform.
- The use of objects makes it possible to lessen and _____ code.
- _____ is a high-level interpreted programming language that uses an object-oriented approach.
- Objects play an integral part in a program because they _____ with other elements and perform certain actions.
Answer Key
- OBJECTS
- CLASSES
- ROUTINES
- COBOL
- IMPERATIVE
- COMPUTER
- METHODS
- REUSE
- PYTHON
- INTERACT
Register to view this lesson
Unlock Your Education
See for yourself why 30 million people use Study.com
Become a Study.com member and start learning now.
Become a MemberAlready a member? Log In
BackResources created by teachers for teachers
I would definitely recommend Study.com to my colleagues. It’s like a teacher waved a magic wand and did the work for me. I feel like it’s a lifeline.