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

From Expertiza_Wiki
Jump to navigation Jump to search
Line 129: Line 129:
* [http://www.developer.com/java/other/article.php/3493761/The-Evolution-of-Object-Oriented-Languages.htm The Evolution of Object-Oriented Languages]
* [http://www.developer.com/java/other/article.php/3493761/The-Evolution-of-Object-Oriented-Languages.htm The Evolution of Object-Oriented Languages]
* [http://www.xp2003.org/the-history-of-oop.htm The History of OOP]
* [http://www.xp2003.org/the-history-of-oop.htm The History of OOP]
* [http://www.brighthub.com/internet/web-development/articles/82024.aspx Structured vs. Object-Oriented Programming: A Comparison]

Revision as of 03:56, 8 September 2011

"Block and Object-Oriented Programming Languages" by Andrew Davis and Srikanth Ramachandran

In computer science, computer programming languages exhibit variance in syntax and structure in order to effectively solve problems. Two of these variances can be seen between block structure and object-oriented structure. A programming language with block structure allows the programmer to group lines of code so that they may be accessed as a single entity. Meanwhile, object-oriented structure allows the programmer to associate data with its actions in a hierarchical manner. Object-oriented structure has many advantages which generally make it more effective and durable than block-structured languages, but object-oriented languages also benefit from ideas present in block structure programming.

Block structure

Definition

Block-structured programming languages are task-centric, high-level languages. Operations on data sets are emphasized rather than the data itself in an attempt to logically organize program operation. The design and implementation involves breaking down the problem into discrete blocks, or units, which can be nested to any depth or not at all. Each block generally consists of a set of delimiters such as braces, indentation, and the like that separate them from other blocks. Each of these blocks contains a set of (optional) declarations and logic to solve a particular problem. Declarations inside of nested blocks introduces the concept of variable scope, which frees the programmer from having to worry about name collisions and other variable maintenance tasks.<ref>Block (programming) at Wikipedia</ref>

Overall, block-structured languages can be summarized as having the following features:

  • Modularization
  • Scope
  • Top down approach
  • Simplicity
  • Dynamic lifetime of variables

History

Block-structured languages were first conceived in the 1950s with the advent of ALGOL, one of the first imperative programming languages. An evolution of block structuring was created as the "GOTO" logic of programs became more and more difficult to understand and maintain. In 1968, famed computer scientist Edsger Dijkstra wrote a letter and follow-up article on the ideas and motivation behind "structured programming," where the program exhibits “separation of concerns," single point of entry but multiple points of exit, and ideas of data structures. It was Dijkstra’s and others’ which helped propel this basic idea of block structure programming into the mainstream.<ref>Structured programming at Wikipedia</ref>

Programming languages

Block-structured programming languages dominate the general purpose, imperative programming language arena. Indeed most programming languages in modern use enjoy some of the benefits of block structure with grouping of code and scope of variables. Indeed, ignoring their object-oriented aspects, all of C, C++, C#, Java, PHP and Visual Basic – for example – contain elements of block structure.

Object-oriented structure

Definition

Description

Object-oriented structured languages are data-centric, high-level languages. Compared to block-structure languages, logical organization of data and the methods associated with them are emphasized. It is a way of grouping data with executable code (called "objects") that works with that data which exhibits attributes in a hierarchical manner (called "classes" in popular languages). Toward this end and depending on the language, objects can be interrelated and defined so that their relationships can produce code that is well-organized, easy to read, and reusable.<ref name="oopref">Object-oriented programming at Wikipedia</ref>

Principles

Encapsulation

Also referred to as "data hiding," encapsulation shields the programmer from the implementation details of an object. These implementation details would include private variables, special libraries, and data structures that the programmer does not need to know in order to utilize the functionality offered by the object.<ref>Encapsulation (object-oriented programming) at Wikipedia</ref>

Inheritance

Inheritance introduces the idea of objects sharing functionality in data or methods that are common. Subclasses can inherit data structures, functions, and attributes of their superclasses in order to create an object hierarchy that is effective in organizing data and methods in a logical manner.<ref>Inheritance (computer science) at Wikipedia</ref>

Polymorphism

Polymorphism describes the idea of interfaces, where one data type can be defined that allows other dissimilar types to implement a common set of methods and fields. This allows a high level of abstraction that allows programmers to write easily maintainable code.<ref>Polymorphism in object-oriented programming at Wikipedia</ref>

History and transition

Early forms of OOP were created in the early 1960s with the creation of LISP and an early form of ALGOL, with Simula 67 signaling the actual beginning of the OOP “revolution." The development of OOP languages progressed through other languages like Smalltalk and the archetypal C++ to arrive at the OOP languages we have today.<ref name="oopref"/>

Programming languages

A complete list of object oriented languages is outside the scope of this document, but some major examples are Boo, C++, C#, COBOL, F#, Fortran 2003, Java, MATLAB, Objective-C, PHP5, Python, Ruby, and Visual Basic.<ref>List of object-oriented programming languages at Wikipedia</ref>

Structure comparison

Advantages and disadvantages

Block Structured Languages

Advantages:
  • Simplicity.
  • Coding and turnover time is quite less.
  • Dynamic lifetime of variables provide efficient usage of memory with allocation and deletion happening at the entrance and exit of each block.
Disadvantages:
  • Commercial projects are very difficult to manage due to very large code base sizes.
  • There is very less code reuse.
  • When arrays are passed as parameters they are usually unbounded,hence it was easy to access an element out of bounds.

Object Oriented Languages

Advantages:
  • The software objects model the real world objects. Hence the program composition is well defined and structured.
  • Since each object's definition and internal working is decoupled from other objects in the system the design becomes inherently modular.
  • Adding new features becomes very easy because of the inheritance feature. The new class can contain the new feature in addition to all old features from the inherited class.
  • Debugging is easier since each objects internal working is independent of each other. This helps in isolating errors easily and fixing them.
  • Code re usability.
Disadvantages:
  • The complexity of O-O design becomes prohibitive when working on small projects.
  • Object-oriented programming paradigm is preferable for dynamic environments rather than simple non complex environments.
  • The time efficiency is much less compared to block structured languages.

Summary of important differences

Difference Block Structured Languages Object-Oriented Languages
Problem approach Top down approach is followed Bottom-up approach is followed
Problem focus Focus is on the Algorithm to solve the problem. Focus is on getting the object design right
View of data and functions Views data and functions as separate entities Views data and functions as single entity
Cost of maintenance Maintenance is costly Maintenance is relatively cheaper
Software reuse Software reuse is not possible Software reuse is possible
Abstraction Function abstraction is used Data abstraction is used

Effectiveness and durability of Object oriented languages over block structured languages

Although block structured languages were simpler and faster for smaller projects, when it comes to large commercial undertaking the manpower and tools required to maintain the code base is very prohibitive. It was very difficult to fix issues ,add new features and at the same time to make sure that the integrity of the code base is intact. Many projects were perpetually stagnant at 90% completion with issues coming up at the nth hour. All these problems led to the hastening of the move to object-oriented languages which showed it had the solutions to all the problems that block structured languages could not solve. The following four points are the most important reasons why object-oriented languages were more effective and durable that block structured languages :

  • Maintenance - In block structured languages especially in large projects system maintenance became a real handful. Object oriented languages could counter this by providing clear demarcation between the objects and making it easier to work on individual aspects of the system without disturbing the other components.
  • Data hiding - In block structured language system the data usually has global scope. Hence it is very difficult to monitor or supervise data access. This was solved by o-o languages by providing data encapsulation. The data and the corresponding attributes are put into a nice little package that was much easier to control and monitor.
  • Code re-use - Object oriented languages are proponents of code reuse. Hence the code size could be reduced sufficiently enough when it comes to large projects to warrant a shift from block structured to object oriented languages.
  • Feature Additions - Object oriented languages provide a very cost effective and safe way to add new features to the existing system without causing the whole system to collapse. This feature is very important for large scale software vendors who provide various customizations.

Applicability between paradigms

Object-oriented languages have solved many problems that block structured languages introduced. But all is not lost with block structured languages. They boast some very important features that are needed in any programming language. The simplicity and readability of code in block structured languages are enviable features indeed. Because of this very simplicity we find that block structured languages are very efficient in terms of speed and performance.Such a language would also provide the flexibility in moving legacy block structured systems to the object oriented paradigm seamlessly. A language that can capture both sides of the argument would be a formidable entry into the growing list of programming languages. This explains why we see C++ emerging as the most popular object oriented language. It has both the block structured features of C and the Object-oriented concepts built into it,thereby making it a very versatile and efficient programming language.

See also

References

<references/>

Further reading

  • Freeman, Eric, Elisabeth Freeman, Kathy Sierra, and Bert Bates. Head First Design Patterns. Sebastopol, CA: O'Reilly, 2004. Print.
  • Liberty, Jesse. Sams Teach Yourself C++ in 24 Hours. Indianapolis, IN: Sams, 2002. Print.
  • Microsoft Visual C++ Language Reference. Redmond, WA: Microsoft, 1997. Print.
  • Weiss, Mark Allen. Data Structures & Algorithm Analysis in Java. Reading, MA: Addison-Wesley, 1999. Print.

External links