?
Solved

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

Posted on 2012-03-15
3
Medium Priority
?
4,450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 29

Assisted Solution

by:pepr
pepr earned 1000 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 1000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

770 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