Unit 1: Introduction to Object Oriented Programming

Topics to be Covered
• Language Paradigms
• Overview of structured programming approach
• Object oriented programming approach
• Characteristics of object oriented languages
Language Paradigms
• Imperative Paradigm – Procedural Programming : C, Pascal, COBOL, FORTRAN etc.
• Applicative Paradigm– Functional Programming – LISP, ML.
• Rule-based Paradigm– Logic Programming :– PROLOG
• Object-Oriented Programming – C++, JAVA, SMALLTALK
Our focus here is on procedural and Object oriented Programming approach.
O-O is a different Paradigm
• Central questions when programming.
– Imperative Paradigm:
– What to do next ?
– Object-Oriented Programming
– What does the object do ? (vs. how)
• Central activity of programming:
– Imperative Paradigm:
– Get the computer to do something.
– Object-Oriented Programming

– Get the object to do something.
Procedural programming approach
In procedural approach,
• A program is a list of instruction(statements).
• When program in PL become larger, they are divided into functions(subroutines, sub- programs, procedures).
• A procedure/function does the particular task for which it is designed.
• Several functions are grouped into a modules.
• Several modules constitutes the large program.
Overview of structured programming approach
• Structured programming
– Also known as modular programming.
– A subset of procedural programming that enforces a top-down design model.
– In top down approach, developers map out the overall program structure into separate subsections to make programs more efficient and easier to understand and modify.
Overview of structured programming approach
• Structured programming uses control structures to control the flow of statement execution in a program.
• The control structures of a programming language let us combine individual statements into a single program entity with one entry point and one exit point.
• We can then write a program as a sequence of control structures rather than a sequence of individual statements.
Overview of structured programming approach There are three categories of control structures:
1. Sequence- Statements executes one after another in sequences.
2. Selection (Decision)- Conditional statements executes base on the test result return by conditional statement.
3. Iteration (Repetition) - Repeate same statement of group of statements multiple times as specified by the control structure.
Overview of structured programming approach
• A pictorial view of structured program.
Overview of structured programming approach�• In a multi function program, two types of data are used: local and global.
– Data items are placed as global so that they can be accessed by all the functions freely.
– Each function may have their own data also called as local data.
Overview of structured programming approachSome points characterizing Procedural approach
• Emphasis is on doing things, (Algorithms)
• Large programs are divided into smaller program – function
• Most of functions share global data.
• Data move openly around system from function to function.
• Function transform data from one form to another
• Uses top-down approach for program design
• In large program, it is difficult to identify which data is used for which function.
• Global variable overcome the local variable.
• To revise an external data structure, all functions that access the data should also be revised.
• Maintaining and enhancing program code is still difficult because of global data. • Focus on functions rather than data.
• It does not model real world problem very well. Since functions are action oriented and do not really correspond to the elements of problem.

Object Oriented Programming


A methodology of programming that

associates data structures with a set of operators which act upon it.

The fundamental concept is to combine or encapsulate both data (or instance variables) and functions (or methods) that operate on that data into a single unit- Object.
– Can model the real world problem representing objects.
– Supports encapsulation, abstraction, inheritance, polymorphism ,message passing to write programs efficiently.
– Examples of OOP languages : Simula, Smalltalk, C++, Python, C#, Visual Basic .NET and Java etc.

Generally in Object Oriented programming

• Emphasis is on data rather than procedures.
• Programs are divided into objects.
• Data structures are designed such that they characterize the objects
• Functions and data are tied together in the data structures so that data abstraction is introduced in addition to procedural abstraction.
• Data is hidden and can’t be accessed by external functions.
• Object can communicate with each other through function.
• New data and functions can be easily added. • Follows Bottom up approach

Characteristics Object Oriented Programming

Object-oriented programming is a programming methodology characterized by the following concepts:
1. Data Abstraction: problem solving via the formulation of abstract data types (ADT's).
2. Encapsulation: the proximity of data definitions and operation definitions.
3. Information hiding: the ability to selectively hide implementation details of a given ADT.
4. Polymorphism: the ability to manipulate different kinds of objects, with only one operation, using different entities in one operation.
5. Inheritance: the ability of objects of one data type, to inherit operations and data from another data type. Embodies the "is a" notion: a horse is a mammal, a mammal is a vertebrate, a vertebrate is a lifeform.

Advantages Object Oriented Programming

• Object oriented programming contributes greater programmer productivity, better quality of software and lesser maintenance cost. The main advantages are:
– Making the use of inheritance, redundant code is eliminated and the existing class is extended.
– Through data hiding, programmer can build secure programs that cannot be invaded by code in other pats of the program.
– It is possible to have multiple instances of an object to co-exist without any interference.
– System can be easily upgraded from small to large systems.
– Software complexity can be easily managed.
– Message passing technique for communication between objects makes the interface description with external system much simpler.
– Aids trapping in an existing pattern of human thought into programming.
– Code reusability is much easier than conventional programming languages.

Disadvantages Object Oriented Programming

➢ Compiler and runtime overhead. Object oriented program required greater processing overhead – demands more resources.
➢ An object’s natural environment is in RAM as a dynamic entity but traditional data storage in files or databases
➢ Re-orientation of software developer to object-oriented thinking.
➢ Requires the mastery in software engineering and programming methodology.
➢ Benefits only in long run while managing large software projects.
➢ The message passing between many objects in a complex application can be difficult to trace & debug.

Application areas of OOP languages

Applications of OOP have importance in many areas.
➢ The most popular application of OOP, up to now has been area of user interface design such as Windows .
➢ Real Business systems are often much more complex attributes & behaviors .
➢ OOP can simplify such complex problem. The areas of application of OOP include
➢ Real time systems
➢ Simulation & modeling
➢ Object-Oriented databases
➢ Hypertext, hypermedia
➢ AI & expert system
➢ Neural Networks & parallel programming
➢ Decision support & Office automation system
➢ CAM/CAD systems
. ➢ Computer Based training and Educational Systems

OO languages vs Object Based Language

• Object Based Language are those having
– Object Identity + support Encapsulation
– Not support Inheritance and dynamic binding
• Examples : Ada, Visual Basic etc.
• Object Oriented Languages-
– Described already
– e.g.
SMALLTALK, JAVA, C++ et.

O-O Principles and C++ Constructs

0 Comments