Sie sind auf Seite 1von 4

http://cplusplusatoz.blogspot.

in/

Programming Paradigms
http://cplusplusatoz.blogspot.in/
Programming paradigms have consistently evolved into a better form, whenever there has been a need.

Monolithic Programming
This approach involved writing programs with relatively flat structure. Program flow control was achieved only through jump statements (similar to goto statement in C++). This made the program structure extremely complex, leading to spaghetti code. There was no support for subroutines. Code needed to be replicated whenever same functionality was required to be performed. Program could consist of only global data. This approach was suitable only for small applications. Example : BASIC

Procedural Programming
As the complexity of programs increased, Monolithic Programming could no longer serve the need. As a consequence, Procedural Programming evolved. The task to be performed by the program was to be broken down into a series of steps, which when performed in sequential order, would result in the desired output. Another name for Procedural Programming is Imperative Programming. Example : Fortran

http://cplusplusatoz.blogspot.in/

http://cplusplusatoz.blogspot.in/

Structured Programming
Even more complex programs, which could not be handled by Procedural Programming, were handled well by Structured Programming. This approach provided support for stand alone subroutines, which eliminated the problem of replicating code whenever an already performed functionality needed to be repeated. Support for local variables was there. Rich control structures were supported, which reduced and in fact, almost eliminated the reliance on jump statements like goto. The programs were organised around their Code . This approach can be thought of as "Code acting on Data". Example : C

Object Oriented Programming


Increasing complexity of programs lead to the evolution of Object Oriented Approach. In this approach, programs are organised around Data. It can be thought of as "Data being acted upon by Code". The type of data defines which code/method can act on it. All Object Oriented languages support three features : Encapsulation, Inheritance & Polymorphism. Example : C++ & Java

Encapsulation
Encapsulation is the mechanism of binding together code and data it manipulates, keeping them safe from external interference and misuse. The concept of Classes is used to support this behaviour. Inside a class, members may be private or public. Public members can still be accessed from outside the class but private members can be accessed only from within the class. The public members provide an interface to the private members of the class.

http://cplusplusatoz.blogspot.in/

http://cplusplusatoz.blogspot.in/

Inheritance
Inheritance is the process which allows on object to acquire properties of another object. This allows for the concept of classification. It becomes easier to think of information as divided into various classes hierarchically. Without classification, all objects would need to be described entirely. However, with classification we can define only the new characteristics which make the object unique within its class.

Polymorphism
Polymorphism is the process in which one interface is used to perform different actions depending upon the context of the situation. For example, a single function name 'area' may be used to calculate the area of more than one kind of objects (figures). C++ supports two kinds of Polymorphism :

Compile time (Static Binding)

Compile time Polymorphism is achieved through Function & Operator Overloading. The Function calls (or bindings) are resolved at compile time.

Run time (Dynamic Binding)

Run time Polymorphism is achieved through Virtual Functions & Inheritance. The Function calls are resolved at Run time.

http://cplusplusatoz.blogspot.in/

http://cplusplusatoz.blogspot.in/

Abstraction & Data Hiding


Abstraction is the process of defining data & program with representation similar to their meaning. Only the relevant details need to be exposed, keeping the rest of the detail safe. Abstraction may be of two kinds :

Control Abstraction : Exposing only the required actions and hiding the rest. For

example, there are private and public member functions inside a class. The public members are accessible outside the class but access to private members outside the class is restricted.

Data Abstraction : Exposing only the required data and hiding the rest. Like

functions, a class may have both public and private data. Private data is not accessible outside the class, unlike public data. This process of hiding some parts of data is also called Data Hiding.

More topics on C++ at the URL given on top.

http://cplusplusatoz.blogspot.in/