3
$\begingroup$

In a description of OOP in my textbook, it is written that “in procedure oriented program the program is organized around its code while in object oriented programming, the program is organized around its data”. What is the meaning of this statement? An explanation with an example would be of great help.

$\endgroup$
-1
$\begingroup$

procedure oriented programming means you can group some operations to finish a task when you know how to do it,step 1,step 2…… object oriented programming means you can inspect a object from two parts,its features (states or data) and its behavior in different states.

$\endgroup$
  • 1
    $\begingroup$ I don't undestand how this answers the question. Can you expand on it a little? $\endgroup$ – Jules Jul 17 '16 at 18:04
-1
$\begingroup$

Before answering the question you have to understand the difference between code and data. Data(input) is a raw fact that manipulates into a new data(output) and Code defines the behaviour like how that data converts to that form.

As we know procedural programming is to divide the program into pieces(module) and then work on separate piece ; These pieces are distinct and interrelated. Every data is local to its piece i.e data is only manipulated by the code within piece.This Doesn't mean the data never be changed , it cannot be manipulated from outside but can be over written. Now the question arises how data be over written?

It is matter of fact that a new module by a new member can accidentally use the variable(data) that is already be used in other module.Thus the value being return from other module is overwritten. Thus insignificance of a data cause a Procedural programming to be organised around code.

Thus Object Oriented programming is build to focus more over Data (Generally both code & data).Like procedural programming having pieces or modules , OOPs having 'Classes';Code & data are bind as an object thus you can independently use the data regarding the class.To overwrite it you have to use the same object regarding of that same class.So in OOPs if a new class is created then there is no way you can overwritten the values because to overwrite the data you need same class in which the object is created.Thus OOPs is organised around data.

$\endgroup$
  • $\begingroup$ This is a very confusing answer. It seems to imply that in procedural programming, data must always be global, which is clearly not true (although it was, of course, historically true for certain languages). It is perfectly possible in more modern procedural languages, however, to separate out data in such a way that it is not accidentally damaged in the way you find. Abstract data types, for example, provide an alternative discipline that can be used in a procedural language and which have similar benefits to those you discuss. $\endgroup$ – Jules Jul 17 '16 at 18:02
  • $\begingroup$ confusing come on .. $\endgroup$ – Bhupinder Singh Jul 19 '16 at 9:06
  • $\begingroup$ Well... if I use a procedural language with useful module structuring (e.g. Modula, or even one of the many extended variants of Pascal) and use abstract data types, how is it a "matter of fact that a new module by a new member can accidentally use the variable(data) that is already be used in other module"? In my experience, such languages have module-scoped variables that prevent accidental reuse of data in this way. So am I missing something? $\endgroup$ – Jules Jul 19 '16 at 12:04
-1
$\begingroup$

There are different approaches to find solutions to problems in computer science.They are called paradigms. Procedural and OOP are two kind of paradigms.

Procedural programming

uses instructions to tell the computer what to do step by step.

For example: cobol,fortran,c

Object oriented programming

approach to problem solving where all calculations are carried out by objects.

For example: java,php,c#

What is the difference?

In Procedural programming The steps of code(instructions) determine and controls the way of working the program.But in Object oriented programming based on objects.An object is a instance of class. Class is a group of objects with common properties and common behaviours. Once you have created class, You can use that class any where in the code.That means , Code doesn't determines the way of working the program.But program is dependant on the internal structure of the class. That means, It is dependant on the attributes and behaviours(data and the way of handling those data). So now It is clear that, “in procedure oriented program the program is organized around its code while in object oriented programming, the program is organized around its data”

$\endgroup$
  • $\begingroup$ Not all object-oriented programming languages use classes. Consider Javascript or Self, for instance. $\endgroup$ – Jules Jul 17 '16 at 18:04
  • $\begingroup$ Yes agree. But javascript is a multi paradigm language.(scriptintg, OOP,Imperative,functional). But when explaining some concepts, Mozilla developer site also uses the word , class. developer.mozilla.org/en-US/docs/Web/JavaScript/… $\endgroup$ – dulaj sanjaya Jul 18 '16 at 2:13
  • 2
    $\begingroup$ classes have recently been added to javascript, but they are emulated using prototypes. The fact that javascript also supports other paradigms doesn't detract from the fact that the core of its OOP implementation is based on prototypes, not classes, and that classes should not be considered to be a core part of OOP itself (Alan Kay, the inventor of the term, has in fact suggested that the use of classes was a mistake... see youtube.com/watch?v=oKg1hTOQXoY) $\endgroup$ – Jules Jul 18 '16 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.