OOP Lecture 1
OOP Lecture 1
[CS1420]
Questions
Objectives History
Benefits of
CONTENT Overview
OOP
Class
Object • Attributes
• Methods
WHAT IS PROGRAMMING?
WHAT IS PROGRAMMING
PARADIGM?
PROGRAMMING PARADIGMS
• Paradigm can also be termed as method to solve some problem or do some task.
• Programming paradigm is an approach to solve problem using some programming language or
also we can say it is a method to solve a problem using tools and techniques that are available to
us following some approach.
• There are lots for programming language that are known but all of them need to follow some
strategy when they are implemented and this methodology/strategy is paradigms.
PROGRAMMING LANGUAGES
Programmers write instructions in various programming languages to perform their computation
tasks such as:
(i) High level Language.
(ii) Low Level Language.
- Machine Language
- Assembly Language
HIGH LEVEL LANGUAGE
• COBOL (COmmon Business Oriented Language)
• FORTRAN (FORmula TRANslation)
• BASIC (Beginner All-purpose Symbolic Instructional Code)
• Pascal (named for Blaise Pascal)
• C (C combines the power of an assembly language with the ease of use and
portability of a high-level language.)
• Visual Basic (Basic-like visual language developed by Microsoft)
• C++ (an object-oriented language, based on C)
• Java (used for developing platform-independent Internet applications)
• C# (a Java-like language developed by Microsoft)
HIGH LEVEL LANGUAGE
The high-level programming languages are broadly categorized in to two categories:
i) Procedure oriented programming(POP) language.
ii) Object oriented programming(OOP) language.
PROCEDURE ORIENTED PROGRAMMING
LANGUAGE
• In the procedure oriented approach, the problem is viewed as sequence of things to
be done such as reading , calculation and printing.
• Procedure oriented programming basically consist of writing a list of instruction or
actions for the computer to follow and organizing these instruction into groups
known as functions.
CHARACTERISTICS OF PROCEDURE
ORIENTED PROGRAMMING
• Employs top-down approach in program design.
• Large programs are divided into smaller programs known as functions.
• Most of the functions share global data .
• Data move openly around the system from function to function.
DISADVANTAGES OF PROCEDURE
ORIENTED PROGRAMMING LANGUAGE
• Global data access .
• It does not model real word problem very well.
• No data hiding.
• Complex problem cannot be solved
• Less efficient and less productive
• Parallel programming is not possible
INTRODUCTION TO OOP
PARADIGM
WHAT IS OBJECT ORIENTATION?
• The object oriented paradigm is a programming methodology that promotes the
efficient design and development of software systems using reusable components that
can be quickly and safely assembled into larger systems.
• It is a technique for system modeling.
• OOP is based on modeling real-world objects.
WHAT IS MODEL?
• A model is an abstraction of something.
• Purpose is to understand the product before developing it.
Example:
Maps, Architectural models , Mechanical models
WHAT IS OBJECT?
• An object is something tangible like : Ali, Car , House etc
An object has its :
• State (attributes)
• Well-defined behaviour (operations)
• Unique identity
EXAMPLE – CAR IS A TANGIBLE OBJECT:
• State (attributes)
- Color
- Model
• behavior (operations)
- Accelerate -
- Start Car
- Change Gear
• Identity
- Its registration number
A D VA N TA G E S
BENEFITS OF OOP:
• Modularity
• Reusability
• Data Redundancy
• Code Maintenance
• Security
• Design Benefits
OBJECT
• The basic unit of abstraction is the OBJECT, which encapsulates
both state information (in the form of the values of instance
variables) and behavior (in the form of methods, which are
basically procedures.)
• Philosophical definition::
- An entity that you can recognize.
• In object technology terms:
person.setName(“Ali");
person.setAge(30);
Lecture 1
C L A SS :
• A group of objects that share common properties for data part and
some program part are collectively called as class.
Informatio
What is
N/A n Actions Example
it?
Contained
Behavior
Blueprin s defined dog
Classes Attributes
t through Templat
methods e
State, Rufus,
Objects Instance Methods
Data Fluffy
EXAMPLE OF CLASS: DOG
CLASS TASK
Identify the data members and member functions for a pizza class. The class should have all the
relevant attributes and qualities required for a pizza object. Try to be imaginative in your design.
For example consider various sizes, toppings, base thickness, etc.
int main() {
MyClass myObj;
myObj.myNum = 15;
myObj.myString = "Some text";