3

From what I understand, procedural programming is a programming paradigm whereby the state of the program is determined by procedures that handle the flow of data, such as subroutines and data-fed function calls while an object oriented program is determined largely by the collective state of its objects, instances, and the interactions between them through interfaces.

Although the data and functionality of a object-oriented program is encapsulated and possibly polymorphic, the entire program is still executed as a procedure broken into smaller tasks; data is still passed around and acted on by object functions and subroutines.

Even in a language like Java (which is described as being exclusively OO), program execution and data flow seems to happen in sequence and using functions and variables.

It appears to me, the concepts in procedural programming still exist in OOP but are extended on, so why does it seem as though the two are contrasted? Am I missing something?

Mode77
  • 991
  • 8
  • 28
  • It helps breaks down a complex problem into smaller familiar parts. For example, in a commerce application you will see objects such as `Cart`, `CartItem`, `CheckoutManager` etc. It helps devs easily communicate with eachother: *The cart is not showing the correct quantity on the UI, maybe we have a bug in the `Cart` class*. A class diagram will show the whole application in familiar names that a BA will also understand. It has more advantages but OO is not the replacement for procedural; just another approach. – CodingYoshi Sep 11 '18 at 21:23

1 Answers1

2

Think of OOP as an organizational layer on top of Procedural. It's an evolution of improvements meant to help you organize, find and connect your code. At the heart of it, it's also Procedural.

The first caveman programmers wrote with no control structures except ones like "if(x!=0)goto y" (jump not zero, jump eq zero,etc) and no variables except "Memory address 17", everything since then have been incremental improvements to make our lives easier. You don't need them, you can stop any time along the way (like for shell scripting, full OO is an overkill, functional makes sense)

Bill K
  • 62,186
  • 18
  • 105
  • 157