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

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.
searchsanjaysharmaAsked:
Who is Participating?
 
ambienceCommented:
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
 
peprCommented:
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
 
searchsanjaysharmaAuthor Commented:
ok
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.