Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TTimer no longer functioning 7 84
multi threaded debug dll option in visual studio 2 95
Header of docx file 17 96
VS2015 Redefinition errors 4 23
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.

930 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

19 Experts available now in Live!

Get 1:1 Help Now