lecture 01 of programming

24
Object Oriented Programming Using C++ Programming Language

Upload: khan

Post on 08-Jul-2016

214 views

Category:

Documents


1 download

DESCRIPTION

Javed Khan S0ns...

TRANSCRIPT

Page 1: Lecture 01 of Programming

Object Oriented Programming

Using C++ Programming Language

Page 2: Lecture 01 of Programming

About this course

In this course we will learn about a new programming technique called object-oriented programming.

Concepts will be reinforced by their implementation in C++ (We will program in C++)

Page 3: Lecture 01 of Programming

About this course…

• 4 Credit Hrs.• 2 Lectures / Week• Each Lecture 1.5Hr.• 1Hr. Lab

Prerequisites• Introduction to Programming and C

Programming

Page 4: Lecture 01 of Programming

Assessment Criteria

Page 5: Lecture 01 of Programming

Syllabus

• Textbook– C++ How to Program By Deitel & Deitel

• Reference Material– The C++ Programming Language By Bjarne Stroustrup

– Object-Oriented Software EngineeringBy Jacobson, Christerson, Jonsson, Overgaard

• Tools– GCC (GNU C Compiler)– Linux (Recommended) / Windows (Not Recomm)

Page 6: Lecture 01 of Programming

Course Contents

• Object-Orientation• Objects and Classes• Overloading• Inheritance• Polymorphism• Generic Programming• Exception Handling• Introduction to Design Patterns

Page 7: Lecture 01 of Programming

Lecture # 1

Introduction to Object Orientation

Page 8: Lecture 01 of Programming

Non-structured Programming

e.g. Assembly Language, BASIC

•Advantages– Low Level access– High Optimization– Shorter size programs

•Disadvantages– Large programs highly complex– Difficult to understand– Repetition of code

a 100 mov ax,0002 mov bx,0004 add ax,bx nop

Page 9: Lecture 01 of Programming

Procedural/Structured Programming

e.g. C, Pascal•Advantages– Fast execution– Small memory footprint (Size)

•Disadvantages– Limited in Enhancement over the time– Low reusability – Difficult to Extended– Less Dynamic architecture

Page 10: Lecture 01 of Programming

Object Oriented Programminge.g. C++, C#, Java etc•Disadvantages– Little Slow execution– Little Big memory footprint (Size)

•Advantages– Better Enhancement over the time– High reusability – Easy to Extended– Better representation of real world problems

Page 11: Lecture 01 of Programming

OBJECT-ORIENTATION (OO)

Today we will learn about Object Orientation technique for solving real world problem.

Page 12: Lecture 01 of Programming

What is Object-Orientation?

• A technique for system modeling

• OO model consists of several interacting objects

Page 13: Lecture 01 of Programming

What is a Model?

• A model is an abstraction of something– Prototype/Architecture of a building

• Purpose is to understand the product before developing it

E.g. Highway maps, Architectural models, Mechanical models

Page 14: Lecture 01 of Programming

Example – OO Model

Page 15: Lecture 01 of Programming

…Example – OO Model

• Objects– Ahmad– House– Car– Tree

• Interactions– Ahmad lives in the house– Ahmad drives the car

Ali

Car

House

Tree

lives-in

drivesAhmad House

Car Tree

Drives

Lives in

Page 16: Lecture 01 of Programming

…Example 2 – Workshop

• ObjectsMechanic, Car, Owner, Registration, Doors, Tyre

Ali

Car

House

Tree

lives-in

drivesMechanic

Registration

Car

Doors

Has

Belongs to

• InteractionsRepair, Ownership, Registered to,

Containment

Tyre

Alirepair

Page 17: Lecture 01 of Programming

Object-Orientation - Advantages

• People think in terms of objects

• OO models map to reality

• Therefore, OO models are– easy to develop– easy to understand

Page 18: Lecture 01 of Programming

What is an Object?

An object is

• Something tangible (possess physical existence )– E.g. Ahmad, Car

• Something that can be apprehended intellectually (Time, Date)

• Nouns

Page 19: Lecture 01 of Programming

… What is an Object?

An object has

• State (attributes)• Well-defined behavior (operations)• Unique identity

Page 20: Lecture 01 of Programming

Example – Ahmad is a Tangible Object

• State (attributes)– Name– Age

• behavior (operations)– Walks– Eats

• Identity– His name / NIC Number

Page 21: Lecture 01 of Programming

Example – Car is a Tangible Object

• State (attributes)- Color- Model

• behavior (operations)- Accelerate- Start Car- Change Gear

• Identity- Its registration number

Page 22: Lecture 01 of Programming

Example – Time is an Object Apprehended Intellectually

• State (attributes)- Hours - Seconds- Minutes

• behavior (operations)- Set Hours - Set Seconds- Set Minutes

• Identity- Would have a unique ID in the model / Date Type

Page 23: Lecture 01 of Programming

Example – Date is an Object Apprehended Intellectually

• State (attributes)- Year - Day- Month

• behavior (operations)- Set Year - Set Day- Set Month

• Identity- Would have a unique ID in the model

Page 24: Lecture 01 of Programming

Q & A