Sie sind auf Seite 1von 17

Object Oriented 1

Programming (EE-123)
BY ENGR. SYED ASAD ALI
LECTURER (ELECTRICAL ENGINEERING)
2
Points To Ponder

 PUNCTUALITY
 If any student is late by 5 minutes, (s)he will be marked absent but Allowed to sit in Class.
 No quiz/assignment/hourly exam will be retaken if a student was absent.
 Late submission leads to a marks deductions
 SINCERE TO LEARN (Learn and Let Others to Learn)
 Unbearable, taunting and distracting behavior will be dealt strictly and may lead to disciplinary action against
him/her
 Student may not be allowed to appear in further classes and exams.
 Use of handheld device is prohibited during Lecture and penalized.
 Keep phone on Silent and Seek permission to use in case of emergency

 BE RESPONSIBLE
 Students are responsible to regularly check the announcements (Notice Board, LMS , Class). Failing to do so
cannot be accepted as an excuse.
3
Course synopsis & Books

 Objectives:
 To familiarize the students with the fundamental concepts of object oriented programming.
 Practice key features of object-oriented programming language using C++.
 To capable students to Use these concepts in solving real life problems.
 Reading Material
 Starting Out With C++ By Tony Gaddis 7th Ed
 Object Oriented Programming in C++ By Robert Lafore 4th Ed
 My Lectures Slides & Our Old Friend.. Mr. oogle !
 Prerequisite
 Introduction to Computing & Programming (EE-121)
4
Program and Teacher

 Program & Section


 BE (Electrical Engineering) :: Miscellaneous
 Credit Hour
 Theory: 2 & Lab:1
 Facilitator:
 Engr. Syed Asad Ali (Theory)
 Email: asad.ali@dsu.edu.pk or syed_asad@ymail.com
 Room # SF 218 (pl see notice board at the office door before consultation)
 Web :: https://sites.google.com/site/easadclass/ or Google easadclass
 Ext 161
Week and
Brief Contents Assessment
Sessions

Lectures 2  Introduction to object-oriented programming language


 Chapter # 9
Lectures 5  Introduction to Pointer Variables
 Pointer Arithmetic, Initializing the Pointers Quiz # 1
 Chapter # 11 VIVA # 1
Lectures 5  Introduction to Structured Data Hourly # 1
 Accessing Structure Members & Initializing a Structure Probably After
Lecture # 20th
 Chapter # 13, 14 & 15
 Introduction to Classes
 Defining an Instance of a Class
Lectures 20  Constructors & Destructors
 Instance(Object) and Static Members
 Other Member Functions
 Inheritance
Lectures 2 • Quiz, Hourly and Viva Examination
Lectures 2 • Course Revision and Final Exam Overview
Marks & Grading Criteria 6
Marks

Quiz (Only One)


VIVA 10%
10%

Final Examination
50%
Hourly Tests (Only One)
30%
7
SUGGESTED READING

Lecture # 1-2 OBJECT ORIENTED PROGRAMMING


LANGUAGE
BY ENGR. SYED ASAD ALI
WHAT AND WHY..??
8
Object oriented Vs Procedural
Oriented programming language

 Procedural programming and object-oriented programming are


two ways of software development and program design.
 In Course EE121, you have learned to write procedural programs.
 Procedural programs are made up of:
 Procedures (Functions)
 Set of Instructions to Perform Desired Operation
 Data (Stored in Variables)
 Usually the data in a procedural program are passed to the functions that
perform the desired operations.

 Functions and data are separate Entity (Not Encapsulated Together)


Cont.. 9
 Object-oriented programming (OOP) is a programming paradigm based
on the concept of "objects & Class“
 Class:
A general Idea , A general Concept
 e.g. Human , Car etc. Encapsulation
(Combination) of
 This Idea Reveals Attributes & Behaviors Functions and data is
Class
 e.g. Name, Age , Run , Walk or Talk etc.
 Object
A realization of this Idea or Concept is Object
 e.g. Ali, 28 , Honda etc.
We will learn about Objects and Classes in detail in Ch: 13 & 14 but first we
should know why Opp !
10
Why OOP? – Problem Solving in Real
Life
 Example Problem1: Assembling a PC
 Suppose that you want to assemble your own PC
 You go to a hardware store and pick up:
 Motherboard, Processor, RAMs, Hard disk, Casing, Power supply, and put them
together.
 Voila ! Your PC runs when turn on the power. It is not difficult to set up a
machine from hardware components.
 You need not to worry about whether:
 How's these Hardware components works……
 Nor you think to re-invent it them!
 Isn't it?

 All you have to make sure that you have assemble them correctly with proper interfaces
11
Cont.…

 Example Problem2 : Assembling a Car:


 Similarly, a car is assembled from parts and components
 Chassis, Doors, Engine, Wheels, Brake, and Transmission.

 The components are reusable.


 e.g., a wheel can be used in many cars (of the same specifications).

 Hardware are normally assembled from parts.


 How about software?
 Can you "assemble" a software application by picking a routine from here & there, and expect
the program to run?

 The answer is obviously no! Unlike hardware, it is very difficult to "assemble" an


application from software components.
 Why …?
12
Limitation of Procedural-Oriented
languages Approach
 Since the advent of computer 60 years ago, we have written tons and tons
of programs. However, for each new application, we have to write the
program from scratch Till 70s.
 Rather Reusing the Component, we re-invents the Component!
 The Procedural-Oriented programs are made up of
functions and functions are often not reusable.
 Functions are likely to reference the headers, global
variables and other functions.
 With this Approach you cant reuse the software
components rather Re-invents it
 Writing from the scratch
13
Two Main Limitations

1. Procedural-Oriented languages are centered on functions


which are not well-encapsulated as a self-contained reusable
unit.
1. Depends upon other variable, Functions or Hader Files

2. A top to Bottom Programming approach become complex to


capture real life problems
 if-else, for-loop, array, function, pointer, are hard to abstract real problems.
14
Origin of OOPs

 In 1970s, the US DoD commissioned a task force to investigate why its IT budget
always went out of control; but without much to show for.
 The findings are:
1. 80% of the budget went to the software
 More than 80% of the software budget went to maintenance (only the remaining 20% for new software
dev elopment).

2. Hardware components could be applied to various products


 Hardware can share and reuse!

3. Software procedures were often non-sharable and not reusable.


 The task force proposed to make software behave like hardware OBJECT.
 Subsequently, DoD replaces over 450 computer languages, which were then used
to build DoD systems, with an object-oriented language called Ada.
15
Object oriented programming
language

 Object-oriented programming (OOP) languages


are designed to overcome these problems.
 By creating a self-contained unit an Object.
 An object may be treated as a Box that
encapsulates both the attributes(Characteristics)
and behaviors(functions) within a "box", and
specifies the public interface for using these
boxes.
 To Create an object we first create its class.
 Object is the realization of class
 In OOP languages (such as Java, C++, C#) uses
software objects to solve the problem.
16
Use of software objects to Solve Pbs:

What are the common object you need in a Soccer game


17
Foundation of object-oriented
programming:

 Classes and Objects


 Abstraction
 Encapsulation
 Inheritance
 Polymorphism

Das könnte Ihnen auch gefallen