Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
in Object Oriented Programming why importance give to data not to code. and in Procedural oriented programming why more importance give to code not to data.
Posted
Updated 6-Oct-13 4:30am
v2
Comments
OriginalGriff 6-Oct-13 10:20am    
What does your question mean? I don't know that either... :laugh:
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Sergey Alexandrovich Kryukov 6-Oct-13 10:46am    
It's a pretty common primitive profanation of some ideas on methodology, which are not directly related to OOP. I answered somehow.
—SA
OriginalGriff 6-Oct-13 10:59am    
You clearly didn't see the first version! :laugh:
Sergey Alexandrovich Kryukov 6-Oct-13 20:57pm    
Now I did... :-)
—SA
HarishVerma 6-Oct-13 10:29am    
in Object Oriented Programming why importance give to data not to code. and in Procedural oriented programming why more importance give to code not to data.

This is nothing but a primitive myth.

1) Yes, there are some different approaches, which could be called "code first" vs. "data structures first", but those approaches are related to software methodology and does not have any absolute character and not directly related to OOP (and they were actively discussed before advent of object-oriented technologies); OOP stimulates "data structures first" approach a little better, but never discourages "code first" approach. 2) "Code first" or "data structures first" does not mean importance; simple common sense should tell you then both aspects are critically important, so you should not try to compare "by importance", it makes no sense at all. 3) Object-oriented programming remains procedure-oriented, you can consider it as a more specialized form of procedure-oriented; let's see: OOP is essentially based on the virtual mechanism, overriding and hence late binding; now, overriding of what? of methods which are still procedures/functions.

—SA
 
Share this answer
 
v2
Comments
pasztorpisti 7-Oct-13 4:05am    
+5, Agreee. Data vs code, this indeed makes no sense...
Sergey Alexandrovich Kryukov 7-Oct-13 4:08am    
Thank you.
Well, on methodological level discussion of such controversy and subtleties makes some sense, but not in the sense of "giving importance"...
—SA
pasztorpisti 7-Oct-13 4:15am    
In case of OOP and procedural both are pretty important, maybe if we spoke about some declarative languages...
Sergey Alexandrovich Kryukov 7-Oct-13 4:23am    
Of course. They are important enough to say that comparison of "importance" makes no sense at all. There can be a lot of subtle controversies of the development method, but it all has nothing to do with "importance" of data or code. And declarative languages are out of scope here.
—SA
What is more important? Is it data or are it methods which process the data?

1.) Data
Let us have data and no method does process it.
--> Useless
2.) Methods
Let us have methods but no data is to process
-->Useless

Both, data and methods are in something “like a symbioses”…more then this, neither data nor methods make sense without the counter part.

It was a “long” time before OOP approach was in discussion where a very clever designer Niklaus Wirth declared data hiding. From my point of view a first approach for OOP. Data are “invisible” (opaque) to the user, but so called “modules” supported the methods to manipulate the data (Wirth investigated MODULA, therefore module, http://en.wikipedia.org/wiki/Modula-2).

Anyway the approach that data becomes a first attention is not wrong, but without the methods data are death 

Kind regards
Idle63
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 6-Oct-13 20:58pm    
Good points, a 5.
—SA
[no name] 7-Oct-13 10:26am    
Thank you very much. Regards, idle63
pasztorpisti 7-Oct-13 4:06am    
5.
[no name] 7-Oct-13 11:28am    
Thanks a lot. Regards, idle63
First of all, you should understand that all these OO and Procedural styles are very simple 'abstract' concepts. Meaning of 'abstract' in the dictionary is ; "existing in thought or as an idea but not having a physical or concrete existence".

And now, Who told you that OOP gives more important to data than code and Procedural programming gives more important to code than data ?

Object-oriented programming simply groups some code and some data. That's it, and you can never say that OOP gives more important to data or the other way around.
 
Share this answer
 
Your statement/question does not make sense to me
Look at it from a pragamtic point of view:
a) in procedural programming, the client code takes some data and processes it with often intimate knowledge of the data
b) in object oriented approaches the client code tells the data to process, not knowing nor taking care of the data details

The second approach allows to abstract from the data details. It also allows for concepts like dependency injection, etc.

While you can always construct OOP like frameworks in procedural languages, it's rater in-convenient to do so.

My first program...
As a beginner of programming (no matter what language), you start writing one Main function and all processing is done there - huge, ugly, not maintainable.

...with functions...
Then you quickly realize that functions can help organizing the code. The functions are quickly defined (e.g. load data, manipulate data, save results, etc.). The tricky part is then to define what the data is to pass/return to/from the functions. You quickly clutter each function with more and more parameters since yet the last additional info needs to be passed to the function.

...together with the data...
Now, you realize that data entities can be combined into meaningful records: entities that belong together are put together (e.g. a stack "type" contains the data array plus the top position - these two entities only make sense if passed around together).

...tied...
If you care more about "what belongs together stays together", you organize your functions such that functions with strong affinity to a given "type" show that affinity either by name and/or by having the first parameter always being of the respective type. This is then convention only and you look forward to a language where the type and the associated functions are tied.

Here you reach the object based world that combines data with functions. This allows for inforamtion hiding and abstraction. It does not allow for polymorphism yet.

...in varying form...
Sooner or later, you reach the point where it might be handy to pass similar but different instances of some types to a function. E.g. a logging function takes a "message", but you want to pass an "error" or a "warning" or an "info" message object. In this given case, all these types would have one in common, a to_string() function that returns the adequate text representation of the object. The logging function would not have to care about what object is passed, as long as it provides such a to_string() function.

...OOP
So you move on to a language that allows to define polymorphism. Now you reached some object oriented stage.

In all the evolution above, there is no clear focus on data verus code.

Cheers
Andi
 
Share this answer
 
I think my qus answer is this:-

POP approach gives no importance to data. By ‘data’ we mean the information collected from user, the new results obtained after calculations etc. If you are familiar with ‘C programming’, you may recollect “storage classes” in C. In C, a data member must be declared GLOBAL inorder to make it accessible by 2 or more functions in the program. What happens when 2 or more functions work on the same data member ? If there are 10 functions in a program, all these 10 functions can access a global data member. It is possible one function may accidentally change values of this global data member. If this data member is a key element of the program, any such accidental manipulation will affect the whole program. It will be too difficult to debug & identify which function is causing the problem if the program is really big.

In OOP There is no need of “global data types” as in POP and hence data will not flow freely around the program.

www.stepwisedotnet.com
 
Share this answer
 
Comments
Andreas Gieriet 8-Oct-13 17:11pm    
No! Your statemens are incorrect and sloppy.
Why the heck do you propagate having global data in C! This style was already deemed as bad styles in the past century...
It has only bad attributes. If you care about this, you may look e.g. at The Practice of Programming (by Brian Kernighan): page 104: "[...] Avoid global variables; wherever possible it is better to pass references to all data through function arguments [...]". This is knowledge from the past 50 years or so... Programs relying on global data are difficult to maintain,especially since practically all usages of global data can be rewritten as mentioned above. Do you have any reference to why you came up with such a statement? I wonder...

With OOP you have the same issues: if you call the wrong function at the wrong time, you modify the instance and all clients of that instance will be fooled by that.

Cheers
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900