Solved

What are the disadvantages of structured programming/ advantages of Object Oriented Programming

Posted on 2012-03-15
3
4,239 Views
Last Modified: 2012-08-13
1.In structured programming, if a code is to be repeated we can create a function,
and function can be called again and again.Then how it is disadvantageous.?

2.How it lacks data hiding?

Can any 1 tell real time example for these 2. Please dont send links.

3.Difference between Structured/Object oriented prog.
0
Comment
Question by:searchsanjaysharma
3 Comments
 
LVL 29

Assisted Solution

by:pepr
pepr earned 250 total points
ID: 37728327
Structured programming is based on separate buiding the algorithms (more complex functionality functions are build of lower-level functions) and separated definitions of data structures.  A program is the combination of the algorithms and of the data in the sense that the algorithms are passed the data structures to modify or to transform them.

The structured programming was the answer to the software crisis (http://en.wikipedia.org/wiki/Software_crisis).  Basically, when the things gets more and more complex, it is more and more difficult to manage the complexity... until you get to the complexity when the old technology cannot manage.

It is said that structured-oriented programming fails when the code has about 20 thousand lines.  The reality is that more complex projects were built using that approach.  The observation is that new principles were used for such projects.  The key observation was that the authors used better internal identification of the data structures with less interdependencies and more strict protocols when passing the data to functions -- the basics of the object-oriented design (but the program written in languages created for structured-oriented programming).

The object-oriented approach is based on the idea that complex systems that work are constructed of simpler systems that work.  In other words,  the internal details of the simpler systems are not exposed to the more complex level.  The systems and subsystems are modelled by objects that work in cooperation.  The object-oriented languages help to transform the ideas using a formal programming language.

In my opinion, the language should be able to use both approaches.  Because of that I like more the pragmatic "hybrid" languages like C++ or Python.
0
 
LVL 22

Accepted Solution

by:
ambience earned 250 total points
ID: 37762671
At a certain level, I dont think object orientation is the opposite of structured programming or vice versa. The principles of abstraction, encapsulation and other OO principals as well as functional decomposition can be equally enforced or violated by structured or object oriented code.

How you perceive a solution is what makes it OO or structure, how you code it does not. In other words, how you design the code is what makes it OO.

From a thought process perspective, there are notable difference between the two. In structured, you are mostly concerned with dividing a solution into smaller functions based solely on the principle of decomposition and reuse. So break a large function into smaller reusable functions if what you mostly think. The focus remains on functionality, start by writing a function run() then divide it into few and so on till everything is in place. NOTE: There is not restriction that you only divide based on the principal of functionality, you are welcome to divide functions also on the basis of behavior (kind of like how you ascribe methods to a class).

In OO, you take a deviation from the focus on functionality and try to visualize in terms of actors (objects). Think in terms of objects with attributes and behavior and construct the solution based on relations between objects. Keep on adding actors and behaviors till everything is in place. BUT, you also functionally decompose and reuse behavior, and that is why you have private behavior that is nonsensical sometimes (or structured if you allow me to put it that way).

Clearly, the two schools of thought are not dependent upon the choice of languages and even structured languages can be used to code OO solution. In these times, perhaps the biggest difference between the two style is that OO languages have builtin support for writing code that fulfillls principals of OO but in C for example, you'd have to do a lot of stuff yourself. Any C++ program is converted by the compiler into just a sequence of function calls, which could have been written directly by the programmer, so thats about it.

Structured programming does not fail with 20K lines of code, core of Windows, to the best of my knowledge is C based and fairly object oriented and its definitely got to be a huge code base.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37764588
ok
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question