This document introduces four techniques for organizing programs: unstructured programming, structured programming, modular programming, and object-oriented programming. Structured programming involves combining statements into procedures that are called from the main program. Modular programming further groups related procedures into separate modules. Object-oriented programming combines data and functions into objects, encapsulating data and hiding it within member functions, allowing objects to interact by sending messages.
1. Lecture 01
Introduction
to
Programming Techniques
2. What are the Program Organizing
Techniques ?
There are four different techniques, they are
3. Unstructured Programming
Working:
Main program directly operates on global data.
Impractical when the program gets large.
The same statement sequence must be copied if
it is needed at different places. ….
EG: for (I=1;I<=10;I++) …..
cout << ‘*’;
DIS : Program becomes large
…..
4. Structured Programming
(Procedural Programming)
main program procedure
Main ( )
{ add( );
subtract ( );
}
Add ( )
Combine a sequence of statements into a
procedure with calls and returns. { ……}
Subtract( )
{ …..}
5. Structured Programming
(cont.)
Main program coordinates calls to procedures
and hands over appropriate data as parameters.
6. Modular Programming
Procedures of a common functionality are
grouped together into separate modules.
Main program coordinates calls to procedures in
separate modules and hands over appropriate
data as parameters.
7. Problems with Structured and Modular
Programming
Unrestricted access to global data.
Poor modeling of the real world. (Attributes and
behavior are separated - data and methods are
separated)
Can’t create new data type easily.
8. Object-Oriented Programming
• Combine data and functions into object.
(Member Data & Member Functions)
• Member functions are also called methods.
• Member data are hidden within member
functions.
• Data Encapsulation & Data Hiding.
• Objects interact by sending messages to
each other.