Lesson 1 of 0
In Progress

Lecture No.01 Introduction

01.1. Introduction

Course Objective: Objective of this course is to make students familiar with the concepts of object oriented programming. These concepts will be reinforced by their implementation in C++.

Course Contents: The main topics that we will study in the 45 lectures of this course are given below, • Object Orientation • Objects and Classes • Overloading • Inheritance • Polymorphism • Generic Programming • Exception Handling • Introduction to Design Patterns

Recommended Text Book:

         C++ How to Program ( Deitel & Deitel ) 

Reference Books:

  1. Object-Oriented Software Engineering By Jacobson, Christerson, Jonsson, Overgaard (For object oriented programming introductory concepts) 2. The C++ Programming Language By Bjarne Stroustrup (For better c++ understanding)

Object Oriented Programming (CS304) VU

                                                                                    © Virtual University of Pakistan                                       9

Object-Orientation (OO)

What is Object-Orientation?

It is a technique in which we visualize our programming problems in the form of objects and their interactions as happens in real life.

Examples: We have different objects around us in our real life that interact with each other to perform different operations for example,

These objects interact with each other to perform different operations,

Take another example of a School; the objects in a school are student, teacher, books, pen ,school bag, classroom, parents, playground and so on… ,

Ali
Car
House
Tree
Lives in
Drives
A Person A House
A Tree A Car Different Objects
Object Oriented Programming (CS304) VU

© Virtual University of Pakistan 10
Objects in a School

Suppose we want to develop a fee collection system for a school for this we will need to find out related objects and their interactions as happens in real life. In this way we can say that object orientation makes it easier for us to solve our real world problems by thinking solution of the problem in terms of real world objects.

So we can say that in our daily life everything can be taken as an object that behaves in a certain way and has certain attributes.

In object orientation we move our concentration to objects in contrast to procedural paradigm in which we simply write our code in functions and call them in our main program.

01.2. What is a Model?

A model is an abstraction of something real or conceptual. We need models to understand an aspect of reality.
Teacher Student School Bag
Book Pen Playground

Parents Classroom Library
Object Oriented Programming (CS304) VU

                                                                                    © Virtual University of Pakistan                                       11

Model Examples

Highway maps Architectural models Mechanical models

01.3. OO Models:

In the context of programming models are used to understand the problem before starting developing it. We make Object Oriented models showing several interacting objects to understand a system given to us for implementation.

Example 1– Object Oriented Model

Objects Ali, Car, House, Tree

Interactions Ali lives in the house Ali drives the car

Example 2– Object Oriented Model (A School Model)

Ali
Car
House
Tree
lives-in
drives
Object Oriented Programming (CS304) VU

© Virtual University of Pakistan 12

A School Model

Objects Teacher, Student, School Bag, Pen, Book Playground

Interactions Teacher teaches Student. Student has School Bag, Book and Pen

01.4. Object-Orientation – Advantages

As Object Oriented Models map directly to reality as we have seen in examples above therefore,

We can easily develop an object oriented model for a problem. Everyone can easily understand an object oriented model. We can easily implement an object oriented model for a problem using any object oriented language like c++ using its features1 like classes, inheritance, virtual functions and so on…

01.5. What is an Object?

An object is,

  1. Something tangible (Ali, School, House, Car). 2. Something conceptual (that can be apprehended intellectually for example time, date and so on…).

An object has,

  1. State (attributes) 2. Well-defined behavior (operations)
    1 We will study these features in detail in this course
    Teacher
    Book
    Student
    School Bag
    Teaches
    Pen
    Has
    Playground
    Plays-in
    Object Oriented Programming (CS304) VU © Virtual University of Pakistan 13
  2. Unique identity

01.6. Tangible and Intangible Objects

Examples of Tangible Objects:

Ali is a tangible object, having some characteristics (attributes) and behavior as given below,

Ali Characteristics (attributes) Behaviour (operations) Name Age
Walks Eats

We will identify Ali using his name.

Car is also a tangible object having some characteristics (attributes) and behavior given below,

Car State (attributes) Behavior (operations) Color Model
Accelerate Start Car Change Gear

We can identify Car using its registration number

Examples of Intangible Objects (also called as conceptual objects):

Time is an intangible (conceptual) object

Time State (attributes) Behavior (operations) Hours Seconds Minutes Set/Get Hours Set/Get Seconds Set/Get Minutes

We will assign our own generated unique ID in the model for Time object

Date is also an intangible (conceptual) object

State (attributes) Year Day Month
Behavior (operations) Set/Get Year Set/Get Day Set/Get Month

Object Oriented Programming (CS304) VU

© Virtual University of Pakistan 14

We will assign our own generated unique ID in the model for Date object.

01.7. Summary:

• Model is the abstraction of some real word scenario. It helps us to understand that scenario. • Object oriented model of any scenario (problem) describes that scenario (problem) in the form of interacting objects. • We use Object Orientation because it helps us in mapping real world problem in a programming language. • Object Orientation is achieved using objects and their relationships. • Properties of an object are described using its data members and behavior of an object is described using its functions. • Objects may be tangible (physical) or intangible (also called conceptual or virtual). • Generally when we have given a certain problem description, nouns in that problem description are candidates for becoming objects of our system. • There may be more than one aspects of an object • It is not necessary that every object has a specific role in implementation of a problem there may be some objects without any role, like school parking in our school. • It is easier to develop programs using Object Oriented Programming because it is closer to real life.

Lesson Content
0% Complete 0/1 Steps