Monday, November 09, 2009

Programming Paradigms


This post is part of my ongoing effort to familiarize the readers with the commonalities & variabilities of C++/Java/C# programming languages. A tentative outline of this series can be found at Contents.

The first recognized programming language arrived in 1950s. O'Reily has a nice poster on the history of programming languages. At the beginning programs were very monolithic. The data was global and available to the whole program. Modification to a data item affected the entire program. It was extremely hard to maintain a large piece of code. Various paradigms have been introduced over the years to ease the development of complex programs with higher maintainability and reusability of code. There are other paradigms which represent different concepts for the programmatic elements. In this series of post, we will very frequently state procedural and object oriented programming paradigms. So they demand a bit more explanation.

  1. Procedural
  2. Programs are developed in a collection of procedures or sub-routines. There is an entry procedure (e.g. main in C) that calls other procedures to perform the tasks. The procedures form a chain and together accomplish the intended operations.
    Procedural programming is a type of Structured programming where each procedure has local data and modification of the local data does not affect outside of the procedure. But procedure has access to global data and can modify them which in turn may change the state of the entire program.

  3. Object Oriented
  4. Not surprisingly objects are the most fundamental components for OO programming. An object is a data structure consisting of data and a set of functions to manipulate that data. OO defines a set of objects and interaction among these objects. In the implementation the objects are defined in classes. An object is an temporal instance of a class and each object is unique in its running environment. I have drawn a simple class diagram (Fig. 1) and an example object diagram (Fig. 2) for students and teachers who supervise these students in a school.




 
    Principles of OO
    Abstraction: An skeleton view of the concrete object. Properties important for the external users are separated from the unimportant properties.
    Encapsulation/Information hiding: Implementation details are kept hidden from the external users such that changes should not effect the users.
    Modularity: System partitioned into highly cohesive and loosely coupled components.
    Hierarchy: Ranking or ordering of abstractions. There are a lot of sub-principles how to achieve these principle which is out of the context of this blog.

I will explain the implementation buildup of object orientation in our referenced languages when we will write our first program. The seminal book1 written by Grady Booch and co. is highly recommended for in-depth knowledge of OO concepts.

References

  1. Grady Booch, Robert Maksimchuk, Michael Engle, Bobbi Young, Jim Conallen, Kelli Houston. Object-oriented analysis and design with applications, third edition, Third edition. Addison-Wesley.

2 comments:

  1. Hallo Mainull, Wie kann ich HTML lernen,Schriftgröße,Bilder verlinken,Elemente positionieren,Tabellen erstellen usw.(?)
    Quader

    ReplyDelete
  2. @Quader: The best way of HTML learning is to follow the standardization body - World Wide Web Consortium (W3C).

    Follow the link and try with simple HTML tags:
    http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro

    ReplyDelete