You are on page 1of 19

Lecture 1:

Object Oriented Programming


By
Dr. Fakhre Alam
Programming Language
 A programming language is a language that consists of instructions designed
for the computers. Processors only understand machine code as it reaches in
two series of 0’s and 1’s, also known as binary data. Machine code is difficult
to understand, and thus various programming languages are being used
which are more understandable than the machine code and also provides
greater portability.
 There are various standards based on which the classification of
programming languages can be obtained. However, based on the
programming paradigm, one can broadly classify them into three categories:
 Procedural Programming Languages
 Structured Programming languages
 Object oriented Languages.
Procedural Programming Languages

 A programming language that executes a set of commands in order. These


languages are based on the concept defined by the procedure calls. It means
that statements are organized into procedures. These procedures are also
known as subroutines or functions.
 The most important advantage of forming procedures is that the procedures
are compact and they are also bounded by scope. It is written in a step by step
manner, thus it is very easy to follow the smaller programs.
 Examples Pascal. Fortran , COBOL
Procedural Programming Languages
Structured Programming languages

 These languages are based on the top down methodology in which a system
is further divided into compositional subsystem.
 Computer programs in these languages are design with the aid of loops,
sequences and decisions.
 Structured programming is not only limited to the top down approach. It
employs methods using:-
 1. Top down analysis for problem solving: It focuses on dividing the problem
into sub parts and hence simplifies the problem solving.
 2. Modularization for program structure and organization: It organizes large
instructions by breaking them into separate and smaller section of modules,
sub routines and subprograms.
Structured Programming languages
 3. Structured code for the individual modules: Control structures are used to
determine the exact order in which the set of instructions are to be executed.
Therefore, a structured code does not involve GOTO statement as it
represents no certain order of execution.
 Example ALGOL, Pascal, Pl/I, C , Ada
Object Oriented Languages
 Object oriented programming (OOP) is a programming model where
programs are organized around object and data rather than action and logic.
 OOP allows decomposition of a problem into a number of entities called
Object and then builds data and function around these objects.
 The program is divided into a number of small units called Object. The data
and function are build around these objects.
 The data of the objects can be accessed only by the functions associated
with that object.
 The functions of one object can access the functions of other object

 Examples C++, C#, BETA, Java


Fundamental Concepts of OOP
Class
 Class is a user defined data type.
 It is a fundamental packaging unit of OOP technology.
 Class can be defined as a template/blue print that describes the
behaviors/states that object of its type support.
Object
 An Object is a real time entity.
 In other words , an object is an independent software entity with logically
combined data and functions.
 Real-world objects share two characteristics : They all have state and
behavior. Dogs have state (name, color) and behavior (barking, wagging
tail).
 An object is an instance of class.
 You can create many instances of a class,
there is no limit.
 Every object must belong to a class.
Encapsulation

 The mechanism of binding the code and the data it manipulates and keeping
both safe from outside interference is called as encapsulation.
 In other words , the wrapping up of data and its functions into a single unit is
called Encapsulation.
Abstraction
 Abstraction refers to the act of representing essential features without
including the background details or explanation between them.
 Abstraction is one of the key principles of the OOAD (Object oriented
analysis and Design).
 For example , a mobile phone has various features like sms, calling, music
player, camera ,etc. You don't need to know how this things work internally ,
you directly use it. This is possible because of abstraction.
Inheritance
 Inheritance is the concept by which the properties of one class are made
available to another.
 It allows the new classes to be built from the older instead of being rewritten
from scratch.
 The concept of inheritance provides the idea of reusability and extensibility.
Polymorphism

 Polymorphism is a Greek term where poly means many and morph means
form.
 It simply means 'one name multiple forms'.

 The most common use of polymorphism in OOP occurs when a parent class
reference is used to refer to a child class object.
Message Passing
 A message for an object is a request for execution of a procedure , and
therefore will invoke a function (procedure) in the receiving object that
generates the desired result.
 Objects can send or receive message or information.

 Message passing involves name of object, name of function (message) and


information to be send.
 For example, student.mark(name) . Here student is object, mark is
message, name is information.
Message Passing
Reusability
 Object Oriented programs are built from reusable software components.

 Reusability is nothing but re-usage of structure without changing the existing


one but adding new features or characteristics to it. It is very much needed
for any programmers in different situations.
 Also , as discussed above in the inheritance concept , reusability is
achieved through inheritance.
Compare Structured and Object-Oriented Programming

 Structured programming is ideal for development of small programs as it


would beat the purpose spending a lot of time and energy designing classes
when an entire working program could be developed within the same time
period.
 Object-oriented programming takes pride in its suitability for sustaining huge
software and web development projects. This is a far better option than using
structured programming when you have massive code bases.
 As for performance, from a user stand point, the difference between
structured and object-oriented programming may be minimal. However in
some cases the fact that object-oriented programs are slower seeing as
there is extra work the interpreter has to go through to compiler the classes
as opposed to the structure method of running in a top down sequence.

You might also like