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

Oop Lecture 01

The document provides an introduction to programming languages, focusing on the evolution of Object-Oriented Programming (OOP) and its key concepts such as classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It outlines course rules, descriptions, and required materials for a Computer Science course on Object-Oriented Programming using Java and C++. Additionally, it discusses various programming paradigms, including procedural and structured programming, and highlights the limitations of these paradigms compared to OOP.

Uploaded by

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

Oop Lecture 01

The document provides an introduction to programming languages, focusing on the evolution of Object-Oriented Programming (OOP) and its key concepts such as classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It outlines course rules, descriptions, and required materials for a Computer Science course on Object-Oriented Programming using Java and C++. Additionally, it discusses various programming paradigms, including procedural and structured programming, and highlights the limitations of these paradigms compared to OOP.

Uploaded by

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

A Brief Introduction of

Programming Languages
and Evolution of OOP

Instructor Name: Syed Shahzad Hassan


Department of Computer Science, HITEC University Taxila - Pakistan
Rules and Regulations:
▪ Plagiarism: No Student shall submit the words, ideas, images or
information of another person as his/her own.
▪ Attendance: Students must maintain at least 75% attendance in class
and lab sessions or he/she will not be allowed to take course exam as
per the university policy.
▪ Disruption: No Student shall disrupt a Class in such a way that
interferes with the normal process of the session or the learning of
other Students.
▪ Punctuality and Regularity in all theory and lab sessions are
required. No makeup quizzes shall be taken
▪ Deadlines: Request for change in deadlines of class activities,
assignments, presentations and projects etc. shall not be
entertained. At least 5% marks shall be deducted for late submission
within 24 hours of the deadline.
Course Description

▪ Course name: Object-Oriented Programming


▪ Course code: CS 104
▪ Programming language: Java, some topics may be covered in
C++
▪ Credit hours:3+1
▪ Number of quizzes: 6
▪ Number of assignments: 4
▪ Note: Good programming skills needed
Books

 Java_The Complete Reference Twelfth Edition by Herbert


Schildt
 Deitel and Deitel,“JAVA How to program (Early Objects)”,10 th
Ed, 2015.
 “A Object Oriented Programming in C++,” 4/ed by Robert
Lafore (2009)
 Deitel and Deitel,“C++ How to program”,10 th Ed, 2011.
The study of programming languages
5

o The purpose of language is simply that it must convey


meaning.

o Whatever can be said, can be said clearly.

o A programming language is a notation for writing programs.

• A computer program is a collection of instructions that can


be executed by a computer to perform a specific task.
• written by a computer programmer in a programming
language.
Introduction of paradigm and programming
paradigms
6

o Paradigm can also be termed as method to solve some


problem or do some task.

o Programming paradigm is an approach to solve problem using


some programming language.
Overview of programming language types and levels
7
Machine language
8

• Machine language is the language understood by a


computer.

• Very difficult to understand, but it is the only thing that the


computer can work with.

• All programs and programming languages eventually


generate or run programs in machine language.
Machine language
9

• Machine code, consisting of machine language instructions,


is a low-level programming language used to directly
control a computer's central processing unit (CPU).

• Machine language can only be represented by 0s and 1s.


Assembly language
10

• Assembly language is the more than low level and less than
high-level language so it is intermediary language.

• Assembly languages use numbers, symbols, and


abbreviations instead of 0s and 1s.
• MOV R0, #10
Machine language vs Assembly language
11

Machine Language Assembly Language

Assembly language is only


Machine language is only
understood by human beings not
understood by the computers.
by the computers.

In machine language data only In assembly language data can be


represented with the help of binary represented with the help of
format(0s and 1s), hexadecimal mnemonics such as Mov, Add, Sub,
and octa decimal. End etc.
Machine language vs Assembly language
12

Machine Language Assembly Language

Machine language is very difficult Assembly language is easy to


to understand by the human understand by the human being as
beings. compared to machine language.

Modifications and error fixing


Modifications and error fixing can
cannot be done in machine
be done in assembly language.
language.

Execution is fast in machine


Execution is slow as compared to
language because all data is
machine language.
already present in binary format.
Procedural programming languages
13

• The first programming paradigm that a new developer will


learn.

• Fundamentally, the procedural code is the one that directly


instructs a device on how to finish a task in logical steps.

• Example FORTRAN and COBOL language programs.


Procedural programming languages
14

• Procedural programming divides the program into


procedures, which simply contain a series of steps to be
carried out.

• It involves writing down a list of instructions to tell the


computer what it should do step-by-step to finish the task at
hand.
Procedural oriented programming languages
15

• The program code is harder to write.


Limitations

• The procedural code is often not reusable, need to recreate.

• Difficult to relate with real-world objects.


Structured programming languages
16

• Large programs are divided into small programs called


functions, modules, subprogram, subroutines and
procedures.
• Modular programming is another name for this.
• These functions have statements embraced inside curly
braces. Each function is design to do a specific task with its
own data and logic.
Structured programming languages
17

• Information can be passed from one function to another


function through parameters.

• A function can have local data that cannot be accessed


outside the function’s scope.

• Easier to understand

• Machine independent
• Example: C, C++, Java, C#
Problems with Structured Programming
No matter how well the structured programming approach is
implemented, large programs become excessively complex.
Two major problems:
- Unrestricted access
- unrelated functions and data
Problems with Structured Programming

Unrestricted Access:
In a procedural program, one written in C for example, there are
two kinds of data.
Local data: is hidden inside a function, and is used
exclusively by the function
Global data: can be accessed by any function in the program
Problems with Structured Programming

Unrestricted access
Unrestricted access:
In a large program, there are many functions and many
global data items.
The problem with the procedural / structural paradigm is
that this leads to an even larger number of potential
connections between functions and data
Problems with Structured Programming

Unrestricted Access:
This large number of connections causes problems in several
ways. First, it makes a program’s structure difficult to
conceptualize.
Second, it makes the program difficult to modify.
A change made in a global data item may necessitate rewriting all
the functions that access that item.
Problems with Structured Programming

Real-World Modeling: problem with the procedural


paradigm is that its arrangement of separate data and
functions does a poor job of modeling things in the real
world
In the physical world we deal with objects such as people
and cars
Complex real-world objects have both attributes and
behavior.
Object oriented programming languages
24

• OOP is a programming paradigm that relies on the concept


of classes and objects.

• It is used to structure a software program into simple,


reusable pieces of code blueprints (usually called classes)
which are used to create individual instances of objects.
Object oriented programming languages
25

• OOP is a fundamental programming paradigm

• In this type of language, programs are divided into objects.

• Prime focus is on the data that is being operated and not on


the functions or procedures.

• Data is hidden and cannot be accessed by external


functions.

• Program structure follows “Bottom UP Approach”.


Object Oriented Programming

Object-oriented programming: A programming paradigm


where a software system is represented as a collection of
objects that interact with each other to solve the overall task
Major OO concepts

▪ Object-oriented programming is founded on these ideas:

▪ object/class
▪ information hiding (encapsulation)
▪ inheritance
▪ Polymorphism
▪ Abstraction
Object

An entity that has state and behavior is known


as an object e.g., chair, bike, marker, pen, table,
car, etc.
Classes

• Classes are fundamental components of a C++/JAVA


program.

• A class is an expanded concept of a structure.

• A class is a mechanism for creating user-defined data


types.
Inheritance
• A new class of objects can be
created quickly and
conveniently
by inheritance—the new
class absorbs the
characteristics of an existing
class, possibly customizing
them and adding unique
characteristics of its own.

30
Encapsulation

• The ability to protect some components of the object


from external entities ("private").
• a process of wrapping code and data together into a
single unit, for example, a capsule which is mixed of
several medicines
• It is a way to achieve data hiding because other class
will not be able to access the data through the
private data members.
31
Polymorphism

• Polymorphism means "many forms", and


Polymorphism is the ability of objects to take
on different forms or behave in different
ways depending on the context in which they
are used.
Abstraction

• Abstraction in OOP allows you to model complex


systems by focusing on essential characteristics
and hiding unnecessary (complex) details.
• Abstract classes and interfaces are the primary
mechanisms for achieving abstraction in Java
Attributes
 Examples of attributes (sometimes called
characteristics) are, for people, eye color and job
title; and, for cars, horsepower and number of
doors.
Behavior
 Behavior is something a real-world object does in

response to some stimulus.


 If you ask your boss for a raise, she will generally

say yes or no. If you apply the brakes in a


 car, it will generally stop

 Behavior is like a function

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