Solved

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

Posted on 2012-03-15
3
4,010 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 28

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now