CSC/ECE 517 Fall 2011/ch1 1e sm: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with " == Block Structured Vs Object Oriented Programming ==")
 
Line 1: Line 1:


== Block Structured Vs Object Oriented Programming ==
This article briefs about how [http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented Programming] came into being after [http://en.wikipedia.org/wiki/Structured_programming Structured Programming] prevailed for years and it compares and contrasts the various aspects of these two programming approaches. It sheds some light on the popular belief that Object-oriented technology will alleviate some of the problems associated with structured approaches.
 
 
==The Journey of Language Evolution==
[[File:lanevo.png|600px|thumb|right|Language Evolution]]
 
<p>During the early days of programming language development, [http://en.wikipedia.org/wiki/Assembly_language assembly languages] dealt with code based on machine instructions ([http://en.wikipedia.org/wiki/Operator_(programming operators]) that manipulated the contents of memory locations ([http://en.wikipedia.org/wiki/Operands operands]). The level of control and [http://en.wikipedia.org/wiki/Data_abstraction data abstraction] achieved was very low. When the first higher-level languages appeared, the operators turned into [http://en.wikipedia.org/wiki/Statement_(programming) statements] and operands into [http://en.wikipedia.org/wiki/Variable_(computer_science) variables] and [http://en.wikipedia.org/wiki/Data_structures data structures]. These languages consisted of a collection of variables that represented some [http://en.wikipedia.org/wiki/Data_(computing) data] and a set of [http://en.wikipedia.org/wiki/Procedure_(computer_science) procedures] that manipulated those variables. The majority of traditional programming languages supported [http://en.wikipedia.org/wiki/Abstract_data_types abstract data types]. Thus there is no way to express the commonality between two abstract data types that are similar but not identical, in these languages that support only abstract data types. The [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented paradigm] went a step ahead by allowing the similarities and differences between abstract data types to be expressed through [http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) inheritance], which is a key defining feature of the object-oriented paradigm.</p>
 
 
<p>Thus the assembly languages were followed by [http://en.wikipedia.org/wiki/Procedural_programming procedural languages] such as [http://en.wikipedia.org/wiki/Fortran FORTRAN], [http://en.wikipedia.org/wiki/Algol Algol].. Procedural languages were then followed by structured programming languages. [http://en.wikipedia.org/wiki/Edsger_W._Dijkstra Dijkstra], Jacopini and Naur were the forefathers of structured programming. Dijkstra first discovered that modularized, goto-less programs were more efficient. Jacopini drew the conclusion that any program that could be converted to one of the following structures could be considered as a structured program</p>
 
 
<b>a) Sequential/Concatenation</b>
 
[[File:seq.jpg]]
 
<b>b) Alternation/Selection</b>
 
[[File:alt.jpg]]
 
<b>c) Iteration/Repetition</b>
 
[[File:iter.jpg]]
 
<p>Dijkstra related the structure of the program text to the structure of the computations. According to him, the [http://en.wikipedia.org/wiki/Flowchart flowchart] of a program which represents the dynamic execution of the program statements also represents the logic of the text. By relation the logic and the structure, we can understand the working of a program more clearly. Dijsktra’s primitive structures – sequential, if-then statements (similar to alternation) and while-do, repeat-until(similar to iteration) are more or less the same as Jacopini’s base diagrams depicted above.
 
Dijkstra next came up with a general process flow for all programs:</p>
1.Read data<br>
2.Calculate Solution<br>
3.Print Results<br>
 
<p>These steps are repeated until the [http://en.wikipedia.org/wiki/Computer_program program] is converted to a form which can be easily compiled and executed. He proposed a “[http://en.wikipedia.org/wiki/Top-down_design top-down]” design to help establish correctness based on a block structured format. Programs with a block structure enabled several programmers to work concurrently and also enabled easier [http://en.wikipedia.org/wiki/Software_testing testing] and [http://en.wikipedia.org/wiki/Verification_and_Validation_(software) validation]</p>
 
<p>[http://en.wikipedia.org/wiki/Simula Simula] was the first programming language that had [http://en.wikipedia.org/wiki/Object_(computer_science) objects] and [http://en.wikipedia.org/wiki/Class_(computer_programming) classes] as central concepts. It was the first language to introduce the concept of class and to allow inheritance to be expressed, and it should be recognized as the “mother” of a few object-oriented programming languages. Besides, because object-oriented concepts have also arisen from the [http://en.wikipedia.org/wiki/Artificial_intelligence artificial intelligence] community, it is not surprising that [http://en.wikipedia.org/wiki/Lisp_(programming_language) Lisp] has influenced a number of object oriented languages. The prominence of the object-oriented paradigm has influenced the design of other programming languages. There are languages that incorporate object-oriented constructs into the popular [http://en.wikipedia.org/wiki/C_(programming_language) C], [http://en.wikipedia.org/wiki/Pascal_(programming_language) Pascal] and Modula-2, resulting in the hybrid languages [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/C%2B%2B C++], ObjectPascal and Modula-3.Other languages influenced basically by Simula and [http://en.wikipedia.org/wiki/CLU_(programming_language) CLU], such as [http://en.wikipedia.org/wiki/BETA_programming_language Beta] and [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel] have also appeared and are believed to give good support for the object-oriented paradigm. Although Eiffel and [http://en.wikipedia.org/wiki/Smalltalk Smalltalk] seem to be coherent object-oriented languages with integrated programming environments, C++ has become the most used object-oriented programming language, due to the influence of [http://en.wikipedia.org/wiki/Unix UNIX] and the popularity of the C language from which C++ derived. Finally, [http://en.wikipedia.org/wiki/Java_(programming_language) Java] should look familiar to C and C++ programmers because Java was designed with similar but cleaner constructs; it also provides a more robust library of classes. The dependency graph over time is as shown in the above figure.</p>
 
== Comparison ==
 
=== <b>[http://en.wikipedia.org/wiki/Debugging Debugging]</b> ===
In structured programming debugging of code gets harder as the size of the program increases.<br>
 
In Object Oriented programming debugging of code is easy as we deal with classes and the readability of the code is improved. The other features that aid in debugging are its Modularity and Independence.
=== <b>[http://en.wikipedia.org/wiki/Reusability Reusability]</b> ===
Reusability, the ability of software elements to serve for the construction of many different applications, is the main platform of object-oriented programming. Rather than starting from scratch with each new application, a programmer will consult [http://en.wikipedia.org/wiki/Library_(computing) libraries] of existing components to see if any are appropriate as starting points for the design of a new application. These components will exist in libraries as class definitions. A programmer will select an appropriate class definition from a library and then create a subclass for the application. The subclass will inherit the methods and properties of the library class, add some new ones of its own and possibly redefine the actions of others. The popularity of OOP stems from the support it gives to a software development process that relies upon pre-existing reusable software components. Reusability is particularly useful for developing graphical user interfaces.<br>
 
Code Reusability in Structured programming is in the form of subroutines which can be called multiple times. But these can be used only within a single application.
 
====<b>Added benefits of Reusability</b>====
 
<b>Reliability</b>: Components built by specialists in their field are more likely to be designed correctly and reliably. The reuse of these components across many applications will have given the developers of the components ample feedback to deal with any bugs and deficiencies.
 
<b>Efficiency</b>: The component developers are likely to be experts in their field and will have used the best possible algorithms and data structures.
 
<b>Time Savings</b>: By relying upon existing components there is less software to develop and hence applications can be built quicker.
 
<b>Decreased maintenance effort</b>: Using someone else’s components decreases the amount of maintenance effort that the application developer needs to expend. The maintenance of the reused components is the responsibility of the component supplier.
 
<b>Consistency</b>: Reliance on a library of standard components will tend to spread a consistency of design message throughout a team of programmers working on an application. The library is the basis of a standard that will lend coherency and conformity to the design process.
 
<b>Investment</b>: Reusing software will save the cost of developing similar software from scratch. The investment in the original development is preserved if the developed software can be used in another project. The most reusable software tends to be that produced by the best developers. Reusing software is thus a way of preserving the knowledge and creations of the best developers.

Revision as of 23:38, 8 September 2011

This article briefs about how Object-oriented Programming came into being after Structured Programming prevailed for years and it compares and contrasts the various aspects of these two programming approaches. It sheds some light on the popular belief that Object-oriented technology will alleviate some of the problems associated with structured approaches.


The Journey of Language Evolution

Language Evolution

During the early days of programming language development, assembly languages dealt with code based on machine instructions (operators) that manipulated the contents of memory locations (operands). The level of control and data abstraction achieved was very low. When the first higher-level languages appeared, the operators turned into statements and operands into variables and data structures. These languages consisted of a collection of variables that represented some data and a set of procedures that manipulated those variables. The majority of traditional programming languages supported abstract data types. Thus there is no way to express the commonality between two abstract data types that are similar but not identical, in these languages that support only abstract data types. The object-oriented paradigm went a step ahead by allowing the similarities and differences between abstract data types to be expressed through inheritance, which is a key defining feature of the object-oriented paradigm.


Thus the assembly languages were followed by procedural languages such as FORTRAN, Algol.. Procedural languages were then followed by structured programming languages. Dijkstra, Jacopini and Naur were the forefathers of structured programming. Dijkstra first discovered that modularized, goto-less programs were more efficient. Jacopini drew the conclusion that any program that could be converted to one of the following structures could be considered as a structured program


a) Sequential/Concatenation

b) Alternation/Selection

c) Iteration/Repetition

Dijkstra related the structure of the program text to the structure of the computations. According to him, the flowchart of a program which represents the dynamic execution of the program statements also represents the logic of the text. By relation the logic and the structure, we can understand the working of a program more clearly. Dijsktra’s primitive structures – sequential, if-then statements (similar to alternation) and while-do, repeat-until(similar to iteration) are more or less the same as Jacopini’s base diagrams depicted above. Dijkstra next came up with a general process flow for all programs:

1.Read data
2.Calculate Solution
3.Print Results

These steps are repeated until the program is converted to a form which can be easily compiled and executed. He proposed a “top-down” design to help establish correctness based on a block structured format. Programs with a block structure enabled several programmers to work concurrently and also enabled easier testing and validation

Simula was the first programming language that had objects and classes as central concepts. It was the first language to introduce the concept of class and to allow inheritance to be expressed, and it should be recognized as the “mother” of a few object-oriented programming languages. Besides, because object-oriented concepts have also arisen from the artificial intelligence community, it is not surprising that Lisp has influenced a number of object oriented languages. The prominence of the object-oriented paradigm has influenced the design of other programming languages. There are languages that incorporate object-oriented constructs into the popular C, Pascal and Modula-2, resulting in the hybrid languages Objective-C, C++, ObjectPascal and Modula-3.Other languages influenced basically by Simula and CLU, such as Beta and Eiffel have also appeared and are believed to give good support for the object-oriented paradigm. Although Eiffel and Smalltalk seem to be coherent object-oriented languages with integrated programming environments, C++ has become the most used object-oriented programming language, due to the influence of UNIX and the popularity of the C language from which C++ derived. Finally, Java should look familiar to C and C++ programmers because Java was designed with similar but cleaner constructs; it also provides a more robust library of classes. The dependency graph over time is as shown in the above figure.


Comparison

Debugging

In structured programming debugging of code gets harder as the size of the program increases.

In Object Oriented programming debugging of code is easy as we deal with classes and the readability of the code is improved. The other features that aid in debugging are its Modularity and Independence.

Reusability

Reusability, the ability of software elements to serve for the construction of many different applications, is the main platform of object-oriented programming. Rather than starting from scratch with each new application, a programmer will consult libraries of existing components to see if any are appropriate as starting points for the design of a new application. These components will exist in libraries as class definitions. A programmer will select an appropriate class definition from a library and then create a subclass for the application. The subclass will inherit the methods and properties of the library class, add some new ones of its own and possibly redefine the actions of others. The popularity of OOP stems from the support it gives to a software development process that relies upon pre-existing reusable software components. Reusability is particularly useful for developing graphical user interfaces.

Code Reusability in Structured programming is in the form of subroutines which can be called multiple times. But these can be used only within a single application.

Added benefits of Reusability

Reliability: Components built by specialists in their field are more likely to be designed correctly and reliably. The reuse of these components across many applications will have given the developers of the components ample feedback to deal with any bugs and deficiencies.

Efficiency: The component developers are likely to be experts in their field and will have used the best possible algorithms and data structures.

Time Savings: By relying upon existing components there is less software to develop and hence applications can be built quicker.

Decreased maintenance effort: Using someone else’s components decreases the amount of maintenance effort that the application developer needs to expend. The maintenance of the reused components is the responsibility of the component supplier.

Consistency: Reliance on a library of standard components will tend to spread a consistency of design message throughout a team of programmers working on an application. The library is the basis of a standard that will lend coherency and conformity to the design process.

Investment: Reusing software will save the cost of developing similar software from scratch. The investment in the original development is preserved if the developed software can be used in another project. The most reusable software tends to be that produced by the best developers. Reusing software is thus a way of preserving the knowledge and creations of the best developers.