0% found this document useful (0 votes)
8 views36 pages

OOP Lecture 1

The document introduces Object-Oriented Programming (OOP) and its fundamental concepts, including classes, objects, and programming paradigms. It outlines the course structure, grading distribution, and emphasizes the importance of thinking in objects and practicing coding. Additionally, it discusses the advantages of OOP, such as modularity, reusability, and improved software quality.

Uploaded by

processingwait
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views36 pages

OOP Lecture 1

The document introduces Object-Oriented Programming (OOP) and its fundamental concepts, including classes, objects, and programming paradigms. It outlines the course structure, grading distribution, and emphasizes the importance of thinking in objects and practicing coding. Additionally, it discusses the advantages of OOP, such as modularity, reusability, and improved software quality.

Uploaded by

processingwait
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

OBJECT ORIENTED PROGRAMMING

[CS1420]

LECTURE 1: INTRODUCTION TO OBJECT


ORIENTED PROGRAMMING
Introduction to course, programming paradigms,
introduction to OOP, objects and classes

Engr. Syeda Aimen Naeem


aimen.naeem@jinnah.edu
GRADE DISTRIBUTION
• Quizzes 20%
• Assignment 10%
• Project 10%
• Midterm Exam 20%
• Final Exam 40%
HOW TO GET THE GOALS
 Read and remember:

Read the book , lectures and remember


 Think:

Think in objects, think in class


 Practice:

Do as many coding as possible and make them running


 Ask:

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

• People think in terms of objects


• OO models map to reality
• Therefore, OO models are
- easy to develop
- easy to understand
OBJECT ORIENTED PROGRAMING:
• The object-oriented paradigm shifts the focus of attention from code to data.

• OOP is based on modeling real-world objects

• The general approach of OOP is to view a software system as a collection of


interacting entities called "objects" each of which is defined by an identity, a state
described in terms of member variables, and a behavior described in terms of
methods that can be invoked.
OBJECTIVES:
• Object technology helps build complex applications quickly:
- Applications are created from existing components
• Easier design:
- designer looks at objects as a black box, not concerned with the detail inside
• Software Reuse:
- Classes are designed so they can be reused in many systems or create modified classes using inheritance
• Enhance the software product quality:
- Reliability, Productivity, etc.
• Robustness:
- Classes designed for repeated reuse become stable over time.
Lecture 1

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:

- An abstraction of real-world” object..


ATTRIBUTES/CHARACTERISTICS AND
BEHAVIOR/OPERATIONS:
• The object can perform operations:
• You can ask the object: “what can you do for me?
• An ATM machine object will have the following operations:
Withdraw cash, print receipt, swipe card, and so on.
• An object pen can have the following operations:
Write, leak ink, etc.
• Each object has knowledge (attribute) about its current state:
• The ATM object has the following attributes:
cash on hand, cards recognized, ATM code, etc.
• The pen object has the attributes:
amount of ink remaining, etc.
OBJECT: EXAMPLE 1
ATTRIBUTES/CHARACTERISTICS AND
BEHAVIOR/OPERATIONS:
OBJECT: EXAMPLE 2
ATTRIBUTES/CHARACTERISTICS AND
BEHAVIOR/OPERATIONS:
• An ATM machine object will have the following operations:
- Withdraw
- cash print receipt
- swipe card, and so on.

• The ATM object has the following attributes:


cash on hand, cards recognized, ATM code, etc.
OBJECT: EXAMPLE 3
ATTRIBUTES/CHARACTERISTICS AND
BEHAVIOR/OPERATIONS:
• An object pen can have the following operations:
- Write
- leak ink, etc.

• The pen object has the attributes:


amount of ink remaining, etc.
EXAMPLES OF OBJECTS:
M ESSAGES
• Objects can communicate between each other by sending messages.
• In OOP, objects do things themselves. A "message" is the terminology used when telling an object to do something.
• A message represents a command sent to an object (recipient or receiver) to perform a certain action by invoking
one of the methods of the recipient.
• A message consists of the following:
• Receiving object,
• The method to be invoked, and
• Optionally the arguments of the method.

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.

• Classes are where we create a blueprint for the structure of


methods and attributes.

• Individual objects are instantiated from this blueprint.


CLASS
CLASS AND OBJECTS
• Object Oriented users use the two words class and object interchangeably.
• Classes are static definitions that enable us to understand all the objects of that class.
They are only concepts to help us understand the real world. They do not exist at run
time.
• Objects are dynamic entities that exist in the real world and are available at run time.
• An object is a specific item that belongs to a class, it is called an instance of a class.
CLASS AND OBJECTS

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.

Identify the data members and member functions of:


• Book Class
• Bank Account class
And create 2 object of these classes with different values.
CLASS SYNTAX
class MyClass {
public:
int myNum;
string myString;
};

int main() {
MyClass myObj;
myObj.myNum = 15;
myObj.myString = "Some text";

cout << myObj.myNum << "\n";


cout << myObj.myString;
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy