2. Programming Techniques
• The evolution of programming techniques is
• to make programming languages more expressive
• to develop complex systems more easily
• There are different programming paradigms
• Unstructured Programming
• Procedural Programming
• Modular & Structural Programming
• Object-Oriented Programming
3. Unstructured Programming
• Usually, people start learning programming by writing small and
simple programs consisting only of one main program.
• Here main program stands for a sequence of commands or
statements which modify data which is global throughout the whole
program.
Main Program
Data
4. Drawbacks of Unstructured Programming
• This programming technique can only be used in a very small
program.
• For example, if the same statement sequence is needed at different
locations within the program, the sequence must be copied.
• If an error needed to be modified, every copy needs to be modified.
• This has lead to the idea to extract these sequences(procedure),
name them and offering a technique to call and return from these
procedures.
5. Procedural Programming
• With procedural programming, you are able to combine sequences of
calling statements into one single place.
• A procedure call is used to invoke the procedure.
• After the sequence is processed, flow of control proceeds right after
the position where the call was made.
Main Program
Procedure
6. Procedures
• With parameters and sub-procedures (procedures of procedures) ,
programs can now be written more structured and error free.
• For example, if a procedure is correct, every time it is used it
produces correct results.
• Consequently, in cases of errors you can narrow your search to those
places which are not proven to be correct.
8. Modular Programming
• Modular programming is subdividing your program into separate
subprograms such as functions and subroutines.
• With modular programming, procedures of a common functionality
are grouped together into separate modules.
• A program therefore no longer consists of only one single part. It is
now divided into several smaller parts which interact through
procedure calls and which form the whole program.
9. Modular Programming Program View
Main Program(Also a module)
Data
Data1
Module 2
+
Data Data2
Module1
+Data Data1
Procedure1 Procedure2 Procedure3
The main program
coordinates calls to
procedures in separate
modules and hands over
appropriate data as
parameters.
10. Modular Programming
• Each module can have its own data. This allows each module to
manage an internal state which is modified by calls to procedures of
this module.
• Each module has its own special functionalities that supports the
implementation of the whole program.
11. Structural Programming
• Also structured programming
• A subset of procedural programming that enforces a logical structure
on the program being written to make it more efficient and easier to
understand and modify.
• Certain languages such as Ada, Pascal, and dBASE are designed with
features that encourage or enforce a logical program.
12. Problems with Structured Programming
• Many Functions access the same data, change in data may require
rewriting of all functions. It makes program difficult to modify.
• It makes a program structure difficult to conceptualize.
• Arrangement of separate data and functions does a poor job of
modeling things in real world.
13. Object-Oriented Programming
• OOP is a technique in which programs are written on the basis of
objects. An object is collection of data and functions.
• The fundamental idea behind object oriented programming is to
combine both data and functions into a single unit. Such a unit is
called object.
• Object is derived from abstract data type.
• Object-oriented programming has a web of interacting objects, each
house-keeping its own state.
• Objects of a program interact by sending messages to each other.
• OOP is based on real world modeling
14. Object-Oriented Programming Program View
Object1
Data1+Procedures1
Data Data1
Object3
Data3 +Procedures3
Object2
Data2 +Procedures2
Object4
Data4 +Procedures4
15. Object-Oriented Programming
• In object-oriented programming , instead of calling a procedure which
we must provide with the correct handle, we would directly send a
message to the object in questions.
• Roughly speaking,
• Each object is responsible to initialize and destroy itself correctly.
• Consequently, there is no longer the need to explicitly call a creation
or termination procedure.
• Each object implements its own module.