GeeCON Prague 2014*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Object Oriented Programming Vs  Structured Programming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Object Oriented Programming Vs  Structured Programming" Watch "Object Oriented Programming Vs  Structured Programming" New topic
Author

Object Oriented Programming Vs Structured Programming

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1376
What is the difference between Object Oriented Programming and Structured Programming ?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
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.


Kishore
SCJP, blog
Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
    
    2
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 ]
Joe Borderi
Ranch Hand

Joined: Oct 23, 2004
Posts: 151
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.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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 ]
Gerald Davis
Ranch Hand

Joined: May 15, 2002
Posts: 872
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

Joined: Apr 08, 2004
Posts: 1376
Structured programming is similar to Functional Programming ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

No.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: Object Oriented Programming Vs Structured Programming