• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Object Oriented Programming Vs Structured Programming

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between Object Oriented Programming and Structured Programming ?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's easily a book length topic

The guys who invented Simula (the precursor to Smalltalk which was the origin of "object oriented" stuff) said they just moved data from the stack to the heap. They didn't think it was that profound. If you know just the right amount of computer architecture, it's a very cute remark.

In my head (not necessarily anybody else's) structured programming's signature technique is functional decomposition. Take a big problem, break it down to small, manageable parts. Measures of goodness include high cohesion, low coupling, isolating sites of change, information hiding.

OO's signature techniques might be identifying responsibilities and managing dependencies. Put the code with related responsibilities together in a class. Measures of goodness include high cohesion, low coupling, isolating sites of change, information hiding. (Whoa! Deja vu all over again!) OO introduces a lot of new ideas that I find improve my chances of achieving goodness, and some new words for old ideas that just make us sound more hip.

Ed Yourdon was one of the leading thinkers in what he called "structured stuff" and he called OO "structured structured programming." All the same goals with some new techniques to enable and enforce good things.
 
Ranch Hand
Posts: 1934
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stan James:
That's easily a book length topic

The guys who invented Simula (the precursor to Smalltalk which was the origin of "object oriented" stuff) said they just moved data from the stack to the heap. They didn't think it was that profound. If you know just the right amount of computer architecture, it's a very cute remark.

In my head (not necessarily anybody else's) structured programming's signature technique is functional decomposition. Take a big problem, break it down to small, manageable parts. Measures of goodness include high cohesion, low coupling, isolating sites of change, information hiding.

OO's signature techniques might be identifying responsibilities and managing dependencies. Put the code with related responsibilities together in a class. Measures of goodness include high cohesion, low coupling, isolating sites of change, information hiding. (Whoa! Deja vu all over again!) OO introduces a lot of new ideas that I find improve my chances of achieving goodness, and some new words for old ideas that just make us sound more hip.

Ed Yourdon was one of the leading thinkers in what he called "structured stuff" and he called OO "structured structured programming." All the same goals with some new techniques to enable and enforce good things.



Very well said Stan.
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say the main difference is that structured programming deals with the flow of execution, and not, primarily, with the data. The mathematical basis for structured programming has to do with the elimination of arbitrary jumps (GOTOs) in favor of code blocks and functions. In particular, "information hiding" as it relates to data isn't fully developed in structured programming; structured programming has to do with the organization of the code, rather than the data, and pure structured programming passes data around in the form of function arguments (conceptually, "on the stack").

In contrast, object oriented programming primarily deals with data issues. The object/class paradigm promotes clean, flexible organization of data in the same way that structured programming promotes clean, flexible organization of code. In a pure object oriented approach, the flow of program execution is treated as bits of behavior associated with the packets of data that are "objects".

In my opinion, the best solution to most practical programming problems involves judicious use of both paradigms.
[ February 17, 2005: Message edited by: Warren Dew ]
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I very much like the explanations above.

I've heard those descriptions reduced to a single sentence: Functional programming is code acting on data; OOP is objects controlling code.

Perhaps that description is jargonistic. Nonetheless, if you come to understand the ways that description serves as useful for a one-sentence description, you'll come a long way to understanding the differences between functional and object oriented programming.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by J Borderi:
Functional programming is code acting on data; OOP is objects controlling code.



Be carefull with your terminology: Functional programming *is not* the same as structured/procedural programming! Functional programming is programming without side effects. Prominent functional programming languages are LISP and Haskel.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion, the most significant technical difference between structural and OO programming is that of polymorphism - being able to call "functions" without knowing what implementation will be used.

Actually, to some amount this is also possible in procedural languages, for example by using function pointers. But it's laborious enough that it's only used in rather special circumstances. OO makes it so easy that it becomes the *normal* way of structuring your code.

That opens the door to building abstractions in a totally different way. Whereas a typical procedure gets some data from somewhere, operates on that data, and passes the result to different parts of your code, a well designed OO method will just tell some objects to do something to their own data. The latter can have a very significant effect on the (de)coupling - and therefore the simplicity and flexibility - of the code.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I shouldn't be surprised, but the Wikipedia has pretty darned good articles on Object Oriented, imperative and functional programming with "fair and balanced" comparisons.

http://en.wikipedia.org/wiki/Object-oriented_programming

I kind of go back & forth between saying OO is an easy next logical step in modularizing and information hiding and then saying it turns absolutely everything upside down. With hybrid languages (most of them) you can ease into OO a little at a time. With Smalltalk you have to learn to crawl and walk all over again. The syntax and semantics are as far reversed from what you knew in procedural programming as you can get. I spent a few months on a Smalltalk project and it made my head spin. (In a good way, not like Linda Blair. ) It has simplicity, clarity of thought and internal consistency of great beauty. I'd like to get more exposure to it, but I'm afraid I'd need some hand holding and I haven't found the Smalltalk Ranch yet.
[ February 18, 2005: Message edited by: Stan James ]
 
Ranch Hand
Posts: 872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Procedural programming could be considered action oriented programming. If you call on a procedure , the your intentions are to execute an action; However, with object orientation it might not always be the case because you can declare a object and not execute it.

It might be better to design a system not using UML but with simple boxes that specify actions and sub-ations. But how those actions would change data and state in such diagram is bound me.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Structured programming is similar to Functional Programming ?
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.
 
Attractive, successful people love this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic