SlideShare a Scribd company logo
1 of 33
Download to read offline
Women University of Azad Jammu and Kashmir Bagh
Department of Computer Sciences and Information Technology, Women University of Azad Jammu and Kashmir Bagh
www.wuajk.edu.pk
Object Oriented Programming
CS-3201
Dr. Anees Qumar Abbasi
aneesabbasi.wuajk@gmail.com
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Course Objective
The course aims to focus on object-oriented concepts, analysis, and
software development.
This course provides in-depth coverage of object-oriented
programming principles and techniques using C++, Understanding,
and fundamentals (principles) of object-oriented programming:
abstraction, encapsulation, polymorphism, and inheritance.
Strong skills in Object Oriented programming will help students to
boost their skills in software development
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Background
• It is expected that you have experience of
writing and understanding programs with C.
• It is also expected that students will have the
knowledge of Functions, structures and
Pointers.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Course Outline
1. Introduction to OOP:
1. What is OOP and its benefits?
2. Basic concepts: objects, classes, encapsulation,
inheritance, and polymorphism.
3. Comparison between procedural programming
and OOP.
2. Classes and Objects:
1. Defining classes and objects.
2. Attributes and methods.
3. Constructors and destructors.
4. Access modifiers: public, private, and
protected.
3. Inheritance and Polymorphism:
1. Inheritance: extending classes, base class, and
derived class.
2. Method overriding and method overloading.
3. Polymorphism: compile-time and runtime
polymorphism.
4. Encapsulation and Abstraction:
1. Encapsulation: data hiding and
accessors/mutators.
2. Abstraction: abstract classes and interfaces.
3. Difference between encapsulation and
abstraction.
5. Association, Aggregation, and Composition:
1. Relationships between classes.
2. Association: simple and directional
relationship.
3. Aggregation: "has-a" relationship.
4. Composition: strong ownership relationship.
6. Exception Handling:
1. Handling runtime errors and exceptions.
2. Try-catch blocks and exception propagation.
7. Additional Topics (time permitting):
1. Polymorphism with interfaces.
2. Abstract classes vs. interfaces.
3. Method overriding and final classes/methods.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Course Material
Main Material
Will be available through slides and Notes
Reference Books:
Object Oriented Programming in C++, Fourth
Edition By RoberLafore,
C How to Program, Sixth Edition Dietal & Dietal
Object Oriented Programming in C++, IT Series
www.codeproject.com
www.codeguru.com
www.howstuffworks.com
www.whatis.com
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Course Communication
Email:
aneesabbasi.wuajk@gmail.com
Piazza:
Piazza is a cloud-based social learning platform, which helps teachers
manage classes, create student groups, post announcements, share files
and lecture videos and participate in class discussions with students.
Please Join:
https://piazza.com/women_university_of_ajk_bagh/spring2023/cs3201
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
How to get the goals?
Read and remember
Read the books, remember the language
Think
Think in objects, think in classes
Practice
Do as many coding as possible and make them running
Ask
Email me questions
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Programming is the process of creating computer
programs by writing instructions in a programming
language to solve specific problems or automate tasks.
It is a fundamental skill in the field of computer science
and plays a crucial role in the development of software and
technology.
Programming is like writing.
If you can write a demonstration, you can make a program
So, programming is also easy.
Programming
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Programming
But, actually, programming is not so easy, because a real
good program is not easily programmed.
It needs the programmers’ lots of wisdom, lots of
knowledge about programming, and lots of experience.
It is like writing, to be a good writer needs lots of
experience and lots of knowledge about the world.
Learning and practice are necessary.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Programming Techniques
The evolution of programming techniques is:
to make programming languages more
expressive
to develop complex systems more easily
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Programming Techniques
Unstructured Programming
Procedural Programming
Modular & Structural Programming
Object-Oriented Programming
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Unstructured Programming
Unstructured programming is a historical
programming technique characterized by a
lack of high-level organization and control
structures. It heavily relies on sequential
execution.
Usually, people start learning programming by
writing small and simple programs consisting
only of one main program.
Here ``main program'' stands for a sequence
of commands or statements which modify data
that is global throughout the whole program.
Main Program
Data
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Drawbacks
Readability and Maintainability
Code Duplication
Spaghetti Code
Limited Abstraction
Limited Reusability
Difficulty in Error Handling
Lack of Scalability
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Procedural Programming
Procedural programming emphasizes the use
of procedures or functions to structure code.
It focuses on step-by-step procedure
execution, with a main program coordinating
the execution of smaller procedures.
With procedural programming, you are able to
combine sequences of calling statements into
one single place.
A procedure call is used to invoke the
procedure. After the sequence is processed,
the flow of control proceeds right after the
position where the call was made.
Main
Program
Procedure
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Procedures
A procedure is a named sequence of instructions or a subroutine
that performs a specific task. It is a reusable block of code that
can be called or invoked from different parts of a program.
Procedures help in organizing code, promoting code reuse, and
improving readability and maintainability.
With parameters and sub-procedures (procedures of procedures),
programs can now be written more structured and error-free.
For example, if a procedure is correct, every time it is used it
produces correct results.
Consequently, in cases of errors you can narrow your search to
those places which are not proven to be correct.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Procedural Program view
Main Program
Data
Procedure1
Procedure2 Procedure3
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Modular Programming
Emphasizes breaking down a program into independent and self-
contained modules or components.
Each module represents a specific functionality or task and can be
developed and maintained separately from other modules.
These modules interact with each other through well-defined
interfaces, promoting code reusability, maintainability, and
scalability.
With modular programming, procedures of a common functionality
are grouped together into separate modules.
A program therefore no longer consists of only one single part. It is
now divided into several smaller parts which interact through
procedure calls and which form the whole program.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Main Program(Also a module)
Data
Data Data1
Module2
+
Data Data2
Module1
+
Data Data1
Procedure1
Procedure2
The main program coordinates calls to procedures in separate modules and hands over
appropriate data as parameters.
Procedure3
Modular Program view
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Modular Programming
Each module can have its own data. This allows each
module to manage an internal state which is modified by
calls to procedures of this module.
Each module has its own special functionalities that
supports the implementation of the whole program.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Structural Programming
A subset of procedural programming that enforces a logical
structure on the program being written to make it more efficient
and easier to understand and modify.
It aims to improve the clarity, readability, and maintainability of
code by enforcing a structured control flow.
It emphasizes the use of control structures, such as loops and
conditionals, to provide clear and organized program logic.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Problems with Structured Programming
Many Functions access the same data, change in data may
require rewriting of all functions. It makes program difficult to
modify.
It makes a program structure difficult to conceptualize.
Arrangement of separate data and functions does a poor job of
modeling things in real world.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Object-Oriented Programming
OOP is a technique in which programs are written on the basis of
objects. An object is collection of data and functions.
The fundamental idea behind object oriented programming is to
combine both data and functions into a single unit. Such a unit is called
object.
Object is derived from abstract data type.
Object-oriented programming has a web of interacting objects, each
house-keeping its own state.
Objects of a program interact by sending messages to each other.
OOP is based on real world modeling.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Object1
Data1+Procedures1
Data Data1 Object3
Data3 + Procedures3
Object2
Data2 + Procedures2
Object4
Data4 + Procedures4
Object-Oriented Programming – Program View
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Object-Oriented Programming
In object-oriented programming , instead of calling a procedure
which we must provide with the correct handle, we would directly
send a message to the object in questions.
Roughly speaking, each object implements its own module.
Each object is responsible to initialize and destroy itself correctly.
Consequently, there is no longer the need to explicitly call a
creation or termination procedure.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
What is an Object?
Objects are tangible entities that exhibit some well-defined
behavior (Almost everything is an object).
Object is a fundamental building block that represents a particular
instance of a class.
It is a runtime entity that combines data/fields (attributes) and behavior
(methods) into a single entity.
An object has:
Properties/State (attributes)
Functions/ Well-defined behaviour (operations)
Unique identity
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Example – Ali is a Tangible Object
► State (attributes/properties/fields):
Name
Age
Height
Color
► Behaviour (operations/methods):
Walks
Eats
Sleep
► Identity:
His name
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Example – Car is a Tangible Object
► State (attributes/properties/fields):
- Color
- Model
► Behaviour (operations/methods):
- Accelerate
- Start Car
- Change Gear
► Identity:
- Its registration number
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Example – Time is an Object:
Apprehended Intellectually
► State (attributes/properties/fields):
► Hours
► Seconds
► Minutes
► Behaviour (operations/methods):
► Set Hours
► Set Seconds
► Set Minutes
► Identity
► Would have a unique ID in the model
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Class
► A Collection of objects with same properties and functions is
known as class.
► A class is used to define the characteristics of the objects.
Example:
Person is a class that can be used to define characteristics and
functions of a person.
It can be used to create many objects of type Person, such as Ali,
Imran etc.
All objects of Person class will have same properties and functions.
However, the values of each object can be different.
Each object is known as instance of its class.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Some Facts about OOP
Everything is an object.
Objects perform computation by making requests of each other
through the passing of messages .
Every object has it's own memory, which consists of other
objects.
Every object is an instance of a class. A class groups similar
objects.
The class is the repository for behavior associated with an
object
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Features of OOP
Objects
OOP provides the facility of programming based in objects. Object is an
entity that consists of data and functions.
Classes
Classes are designed to create objects. OOP provides facility to design
classes.
Real-world Modeling
OOP is based on real-world modeling. As in the real world, things have
properties and working capabilities. Similalrly, objects have data and
functions. Data represents properties and functions represents working of
objects.
Reusability
OOP provides ways to reuse data and code (inheritance).
Information Hiding
OOP allows the programmer to hide important data from the user
(Encapsulation)
Polymorphism
Polymorphism is an ability of an object to behave in multiple ways.
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Object Oriented Languages
C++
JAVA
C# (C Sharp)
Python
Many other
Department of Computer Sciences & Information Technology
Dr. Anees Qumar Abbasi- Object-Oriented Programming
Implementation Language: C++
C++ is an Object Oriented language.
It was developed in 1985 at Bell Laboratories.
It is an improved version of C.
It was originally named “C with classes”.
It is very powerful language and is used to develop a variety of
programs.
It is very much compatible with C.

More Related Content

Similar to Lec_1,2_OOP_(Introduction).pdf

Basic Computer.docx
Basic Computer.docxBasic Computer.docx
Basic Computer.docxatulsharmaat
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxvishnupriyapm4
 
Office automation system report
Office automation system reportOffice automation system report
Office automation system reportAmit Kulkarni
 
Office automation system report
Office automation system reportOffice automation system report
Office automation system reportAmit Kulkarni
 
BSC Software & Software engineering-UNIT-IV
BSC Software & Software engineering-UNIT-IVBSC Software & Software engineering-UNIT-IV
BSC Software & Software engineering-UNIT-IVYamunaP6
 
Evaluvation of Applying Knowledge Management System Architecture in Software ...
Evaluvation of Applying Knowledge Management System Architecture in Software ...Evaluvation of Applying Knowledge Management System Architecture in Software ...
Evaluvation of Applying Knowledge Management System Architecture in Software ...IOSR Journals
 
Leveraging software-reuse-with-knowledge-management-in-software-development
Leveraging software-reuse-with-knowledge-management-in-software-developmentLeveraging software-reuse-with-knowledge-management-in-software-development
Leveraging software-reuse-with-knowledge-management-in-software-developmentDimitris Panagiotou
 
A Survey on Design of Online Judge System
A Survey on Design of Online Judge SystemA Survey on Design of Online Judge System
A Survey on Design of Online Judge SystemIRJET Journal
 
Project Management
Project ManagementProject Management
Project ManagementBabu Appat
 
Introduction to software & software engg presented by aniket kr pandey. ...
Introduction to software & software engg presented by  aniket kr pandey. ...Introduction to software & software engg presented by  aniket kr pandey. ...
Introduction to software & software engg presented by aniket kr pandey. ...Aniketkumar204
 
Durgesh o level_2nd_part
Durgesh o level_2nd_partDurgesh o level_2nd_part
Durgesh o level_2nd_partDurgesh Singh
 

Similar to Lec_1,2_OOP_(Introduction).pdf (20)

Project based learning methodologies for Embedded Systems and Intelligent Sys...
Project based learning methodologies for Embedded Systems and Intelligent Sys...Project based learning methodologies for Embedded Systems and Intelligent Sys...
Project based learning methodologies for Embedded Systems and Intelligent Sys...
 
Basic Computer.docx
Basic Computer.docxBasic Computer.docx
Basic Computer.docx
 
OOPM - Introduction.pptx
OOPM - Introduction.pptxOOPM - Introduction.pptx
OOPM - Introduction.pptx
 
Bright copy
Bright   copyBright   copy
Bright copy
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptx
 
Office automation system report
Office automation system reportOffice automation system report
Office automation system report
 
Office automation system report
Office automation system reportOffice automation system report
Office automation system report
 
Nagacv
NagacvNagacv
Nagacv
 
BSC Software & Software engineering-UNIT-IV
BSC Software & Software engineering-UNIT-IVBSC Software & Software engineering-UNIT-IV
BSC Software & Software engineering-UNIT-IV
 
Evaluvation of Applying Knowledge Management System Architecture in Software ...
Evaluvation of Applying Knowledge Management System Architecture in Software ...Evaluvation of Applying Knowledge Management System Architecture in Software ...
Evaluvation of Applying Knowledge Management System Architecture in Software ...
 
Bright
BrightBright
Bright
 
Leveraging software-reuse-with-knowledge-management-in-software-development
Leveraging software-reuse-with-knowledge-management-in-software-developmentLeveraging software-reuse-with-knowledge-management-in-software-development
Leveraging software-reuse-with-knowledge-management-in-software-development
 
A Survey on Design of Online Judge System
A Survey on Design of Online Judge SystemA Survey on Design of Online Judge System
A Survey on Design of Online Judge System
 
Hesham raslan s banjr
Hesham raslan s banjrHesham raslan s banjr
Hesham raslan s banjr
 
Project Management
Project ManagementProject Management
Project Management
 
DivyaVenkatesh_CV
DivyaVenkatesh_CVDivyaVenkatesh_CV
DivyaVenkatesh_CV
 
Online attendance management system
Online attendance management systemOnline attendance management system
Online attendance management system
 
Introduction to software & software engg presented by aniket kr pandey. ...
Introduction to software & software engg presented by  aniket kr pandey. ...Introduction to software & software engg presented by  aniket kr pandey. ...
Introduction to software & software engg presented by aniket kr pandey. ...
 
Durgesh o level_2nd_part
Durgesh o level_2nd_partDurgesh o level_2nd_part
Durgesh o level_2nd_part
 
Student report
Student reportStudent report
Student report
 

More from AneesAbbasi14

Goal Setting UPDATED.pptx
Goal Setting UPDATED.pptxGoal Setting UPDATED.pptx
Goal Setting UPDATED.pptxAneesAbbasi14
 
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdf
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdfLec_15_OOP_ObjectsAsParametersFriendClasses.pdf
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdfAneesAbbasi14
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdfAneesAbbasi14
 
lecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdflecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdfAneesAbbasi14
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptxAneesAbbasi14
 
Yasir Presentation.pptx
Yasir Presentation.pptxYasir Presentation.pptx
Yasir Presentation.pptxAneesAbbasi14
 
IntroComputerVision23.pptx
IntroComputerVision23.pptxIntroComputerVision23.pptx
IntroComputerVision23.pptxAneesAbbasi14
 

More from AneesAbbasi14 (10)

Goal Setting UPDATED.pptx
Goal Setting UPDATED.pptxGoal Setting UPDATED.pptx
Goal Setting UPDATED.pptx
 
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdf
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdfLec_15_OOP_ObjectsAsParametersFriendClasses.pdf
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdf
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdf
 
lecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdflecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdf
 
lec09_ransac.pptx
lec09_ransac.pptxlec09_ransac.pptx
lec09_ransac.pptx
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptx
 
02-07-20_Anees.pptx
02-07-20_Anees.pptx02-07-20_Anees.pptx
02-07-20_Anees.pptx
 
Yasir Presentation.pptx
Yasir Presentation.pptxYasir Presentation.pptx
Yasir Presentation.pptx
 
Lec5_OOP.pptx
Lec5_OOP.pptxLec5_OOP.pptx
Lec5_OOP.pptx
 
IntroComputerVision23.pptx
IntroComputerVision23.pptxIntroComputerVision23.pptx
IntroComputerVision23.pptx
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Lec_1,2_OOP_(Introduction).pdf

  • 1. Women University of Azad Jammu and Kashmir Bagh Department of Computer Sciences and Information Technology, Women University of Azad Jammu and Kashmir Bagh www.wuajk.edu.pk Object Oriented Programming CS-3201 Dr. Anees Qumar Abbasi aneesabbasi.wuajk@gmail.com
  • 2. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Course Objective The course aims to focus on object-oriented concepts, analysis, and software development. This course provides in-depth coverage of object-oriented programming principles and techniques using C++, Understanding, and fundamentals (principles) of object-oriented programming: abstraction, encapsulation, polymorphism, and inheritance. Strong skills in Object Oriented programming will help students to boost their skills in software development
  • 3. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Background • It is expected that you have experience of writing and understanding programs with C. • It is also expected that students will have the knowledge of Functions, structures and Pointers.
  • 4. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Course Outline 1. Introduction to OOP: 1. What is OOP and its benefits? 2. Basic concepts: objects, classes, encapsulation, inheritance, and polymorphism. 3. Comparison between procedural programming and OOP. 2. Classes and Objects: 1. Defining classes and objects. 2. Attributes and methods. 3. Constructors and destructors. 4. Access modifiers: public, private, and protected. 3. Inheritance and Polymorphism: 1. Inheritance: extending classes, base class, and derived class. 2. Method overriding and method overloading. 3. Polymorphism: compile-time and runtime polymorphism. 4. Encapsulation and Abstraction: 1. Encapsulation: data hiding and accessors/mutators. 2. Abstraction: abstract classes and interfaces. 3. Difference between encapsulation and abstraction. 5. Association, Aggregation, and Composition: 1. Relationships between classes. 2. Association: simple and directional relationship. 3. Aggregation: "has-a" relationship. 4. Composition: strong ownership relationship. 6. Exception Handling: 1. Handling runtime errors and exceptions. 2. Try-catch blocks and exception propagation. 7. Additional Topics (time permitting): 1. Polymorphism with interfaces. 2. Abstract classes vs. interfaces. 3. Method overriding and final classes/methods.
  • 5. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Course Material Main Material Will be available through slides and Notes Reference Books: Object Oriented Programming in C++, Fourth Edition By RoberLafore, C How to Program, Sixth Edition Dietal & Dietal Object Oriented Programming in C++, IT Series www.codeproject.com www.codeguru.com www.howstuffworks.com www.whatis.com
  • 6. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Course Communication Email: aneesabbasi.wuajk@gmail.com Piazza: Piazza is a cloud-based social learning platform, which helps teachers manage classes, create student groups, post announcements, share files and lecture videos and participate in class discussions with students. Please Join: https://piazza.com/women_university_of_ajk_bagh/spring2023/cs3201
  • 7. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming How to get the goals? Read and remember Read the books, remember the language Think Think in objects, think in classes Practice Do as many coding as possible and make them running Ask Email me questions
  • 8. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Programming is the process of creating computer programs by writing instructions in a programming language to solve specific problems or automate tasks. It is a fundamental skill in the field of computer science and plays a crucial role in the development of software and technology. Programming is like writing. If you can write a demonstration, you can make a program So, programming is also easy. Programming
  • 9. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Programming But, actually, programming is not so easy, because a real good program is not easily programmed. It needs the programmers’ lots of wisdom, lots of knowledge about programming, and lots of experience. It is like writing, to be a good writer needs lots of experience and lots of knowledge about the world. Learning and practice are necessary.
  • 10. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Programming Techniques The evolution of programming techniques is: to make programming languages more expressive to develop complex systems more easily
  • 11. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Programming Techniques Unstructured Programming Procedural Programming Modular & Structural Programming Object-Oriented Programming
  • 12. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Unstructured Programming Unstructured programming is a historical programming technique characterized by a lack of high-level organization and control structures. It heavily relies on sequential execution. Usually, people start learning programming by writing small and simple programs consisting only of one main program. Here ``main program'' stands for a sequence of commands or statements which modify data that is global throughout the whole program. Main Program Data
  • 13. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Drawbacks Readability and Maintainability Code Duplication Spaghetti Code Limited Abstraction Limited Reusability Difficulty in Error Handling Lack of Scalability
  • 14. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Procedural Programming Procedural programming emphasizes the use of procedures or functions to structure code. It focuses on step-by-step procedure execution, with a main program coordinating the execution of smaller procedures. With procedural programming, you are able to combine sequences of calling statements into one single place. A procedure call is used to invoke the procedure. After the sequence is processed, the flow of control proceeds right after the position where the call was made. Main Program Procedure
  • 15. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Procedures A procedure is a named sequence of instructions or a subroutine that performs a specific task. It is a reusable block of code that can be called or invoked from different parts of a program. Procedures help in organizing code, promoting code reuse, and improving readability and maintainability. With parameters and sub-procedures (procedures of procedures), programs can now be written more structured and error-free. For example, if a procedure is correct, every time it is used it produces correct results. Consequently, in cases of errors you can narrow your search to those places which are not proven to be correct.
  • 16. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Procedural Program view Main Program Data Procedure1 Procedure2 Procedure3
  • 17. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Modular Programming Emphasizes breaking down a program into independent and self- contained modules or components. Each module represents a specific functionality or task and can be developed and maintained separately from other modules. These modules interact with each other through well-defined interfaces, promoting code reusability, maintainability, and scalability. With modular programming, procedures of a common functionality are grouped together into separate modules. A program therefore no longer consists of only one single part. It is now divided into several smaller parts which interact through procedure calls and which form the whole program.
  • 18. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Main Program(Also a module) Data Data Data1 Module2 + Data Data2 Module1 + Data Data1 Procedure1 Procedure2 The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters. Procedure3 Modular Program view
  • 19. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Modular Programming Each module can have its own data. This allows each module to manage an internal state which is modified by calls to procedures of this module. Each module has its own special functionalities that supports the implementation of the whole program.
  • 20. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Structural Programming A subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. It aims to improve the clarity, readability, and maintainability of code by enforcing a structured control flow. It emphasizes the use of control structures, such as loops and conditionals, to provide clear and organized program logic.
  • 21. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Problems with Structured Programming Many Functions access the same data, change in data may require rewriting of all functions. It makes program difficult to modify. It makes a program structure difficult to conceptualize. Arrangement of separate data and functions does a poor job of modeling things in real world.
  • 22. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Object-Oriented Programming OOP is a technique in which programs are written on the basis of objects. An object is collection of data and functions. The fundamental idea behind object oriented programming is to combine both data and functions into a single unit. Such a unit is called object. Object is derived from abstract data type. Object-oriented programming has a web of interacting objects, each house-keeping its own state. Objects of a program interact by sending messages to each other. OOP is based on real world modeling.
  • 23. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Object1 Data1+Procedures1 Data Data1 Object3 Data3 + Procedures3 Object2 Data2 + Procedures2 Object4 Data4 + Procedures4 Object-Oriented Programming – Program View
  • 24. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Object-Oriented Programming In object-oriented programming , instead of calling a procedure which we must provide with the correct handle, we would directly send a message to the object in questions. Roughly speaking, each object implements its own module. Each object is responsible to initialize and destroy itself correctly. Consequently, there is no longer the need to explicitly call a creation or termination procedure.
  • 25. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming What is an Object? Objects are tangible entities that exhibit some well-defined behavior (Almost everything is an object). Object is a fundamental building block that represents a particular instance of a class. It is a runtime entity that combines data/fields (attributes) and behavior (methods) into a single entity. An object has: Properties/State (attributes) Functions/ Well-defined behaviour (operations) Unique identity
  • 26. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Example – Ali is a Tangible Object ► State (attributes/properties/fields): Name Age Height Color ► Behaviour (operations/methods): Walks Eats Sleep ► Identity: His name
  • 27. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Example – Car is a Tangible Object ► State (attributes/properties/fields): - Color - Model ► Behaviour (operations/methods): - Accelerate - Start Car - Change Gear ► Identity: - Its registration number
  • 28. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Example – Time is an Object: Apprehended Intellectually ► State (attributes/properties/fields): ► Hours ► Seconds ► Minutes ► Behaviour (operations/methods): ► Set Hours ► Set Seconds ► Set Minutes ► Identity ► Would have a unique ID in the model
  • 29. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Class ► A Collection of objects with same properties and functions is known as class. ► A class is used to define the characteristics of the objects. Example: Person is a class that can be used to define characteristics and functions of a person. It can be used to create many objects of type Person, such as Ali, Imran etc. All objects of Person class will have same properties and functions. However, the values of each object can be different. Each object is known as instance of its class.
  • 30. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Some Facts about OOP Everything is an object. Objects perform computation by making requests of each other through the passing of messages . Every object has it's own memory, which consists of other objects. Every object is an instance of a class. A class groups similar objects. The class is the repository for behavior associated with an object
  • 31. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Features of OOP Objects OOP provides the facility of programming based in objects. Object is an entity that consists of data and functions. Classes Classes are designed to create objects. OOP provides facility to design classes. Real-world Modeling OOP is based on real-world modeling. As in the real world, things have properties and working capabilities. Similalrly, objects have data and functions. Data represents properties and functions represents working of objects. Reusability OOP provides ways to reuse data and code (inheritance). Information Hiding OOP allows the programmer to hide important data from the user (Encapsulation) Polymorphism Polymorphism is an ability of an object to behave in multiple ways.
  • 32. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Object Oriented Languages C++ JAVA C# (C Sharp) Python Many other
  • 33. Department of Computer Sciences & Information Technology Dr. Anees Qumar Abbasi- Object-Oriented Programming Implementation Language: C++ C++ is an Object Oriented language. It was developed in 1985 at Bell Laboratories. It is an improved version of C. It was originally named “C with classes”. It is very powerful language and is used to develop a variety of programs. It is very much compatible with C.