Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction-Object Oriented Programming-Lecture Slides, Slides of Object Oriented Programming

This lecture was delivered by Dr. Jameel Ahmad at Quaid-i-Azam University for Object Oriented Programming course. It includes: Object, Paradigm Oriented, Programming, Testing, Debugging, Algorithms, Formal, Logic Data, Fields

Typology: Slides

2011/2012

Uploaded on 07/13/2012

saqqi
saqqi 🇵🇰

4

(33)

40 documents

1 / 22

Toggle sidebar

Related documents


Partial preview of the text

Download Introduction-Object Oriented Programming-Lecture Slides and more Slides Object Oriented Programming in PDF only on Docsity!

CS

2113

Object

Oriented

Programming

(OOP)

Course Instructor: Mr. Shahzad Rafiq Office: Room 113, 1 st Floor, Block A, Email: [email protected] Teacher Assistant: Ms. Tehreem Zainab

Questions

for

You

Programming?

Programming

Paradigm?

Object

Orientation?

Programming

Computer programming (often shortened to programming or coding ) is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic. - http://en.wikipedia.org/wiki/

Programming

Paradigm

A

programming

paradigm

is

a

fundamental

style

of

computer

programming.

(Compare

with

a

methodology,

which

is

a

style

of

solving

specific

software

engineering problems.)

Paradigms

differ

in

the

concepts

and

abstractions

used

to

represent

the

elements

of

a

program

(such

as

objects,

functions,

variables,

constraints,

etc.)

and

the

steps

that

compose

a

computation

(assignment,

evaluation,

continuations,

data

flows,

etc.).

http://en.wikipedia.org/wiki/

Object

Orientation

Object

oriented

programming

(

OOP

)

is

a

programming

paradigm using

"objects"

  • data

structures consisting

of

data

fields and

methods

together

with

their

interactions

  • to

design

applications

and

computer

programs.

Programming

techniques

may

include

features

such

as

data

abstraction,

encapsulation,

messaging,

modularity,

polymorphism,

and

inheritance.

Many

modern

programming

languages now

support

OOP,

at

least

as

an

option.

http://en.wikipedia.org/wiki/

The

OO

Model

Four major elements:

Abstraction - Encapsulation - Modularity - Hierarchy

Three minor elements:

Typing - Concurrency - Persistence

Abstraction

A simplified description of a system that emphasizes some of the systems details while suppressing others - Good abstraction will emphasize details that are significant to the user

A concept qualifies as abstract only if it can be described, understood, and analyzed independently of the mechanism that will eventually be used to realize it

Abstraction

A

formal

OO

definition:

An abstraction denotes the essential characteristics of an object that distinguishes it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer

Abstraction

An

abstraction

focuses

on

the

outside

view

of

an

object

Arriving

at

the

right

set

of

abstractions

for

a

given

domain

is

central

to

OO

design

Types

of

Object

Abstraction

Entity

Represents a useful model of a problem ‐ domain entity - Action - Provides a generalized set of operations all of which perform the same kind of function

Virtual ‐ machine

Groups together operations that are all used by some superior level of control or operations that all use the same junior level set of operations

Coincidental

Packages a set of unrelated operations

Abstraction

example

Controlling the cabin of a plane

Key abstraction is a sensor - Anything we will measure must be associated with - a sensor (pressure, temp, moisture, smoke) - Actions the sensor would need to perform: - Calibrate - Test - Report - Set

Encapsulation

Once the level and type of abstraction is selected the implementation that defines the abstraction should remain a secret

No part of a complex system should depend on the internal details of any other part - Encapsulation permits programs to change with out impacting other objects and models - Abstractions gives the outside view to the user while encapsulation insulates the user from the details

Encapsulation

Also known as information hiding

For abstraction to work, encapsulation must be present

2

distinct parts defined now:

Interface

  • captures the outside view - Implementation mechanics to achieve the desired behavior

Modularity

The act of partitioning a program into individual components can reduce the complexity to some degree

Even more powerful is the modular partitioning of a system creating well

defined and documented boundaries.

Each boundary has an interface - This leads to greatly increased comprehension of a program

Modularity

We

build

classes

which

form

the

logical

structure

and

are

housed

in

modules

which

build

the

physical

structure

of

the

system

» In C++ the interface is often declared in a header file and the implementation is hidden

So

in

C++,

modularity

and

encapsulation

go

well

together.

Modularity

In

traditional

design,

modularization

is

concerned

with

the

meaningful

grouping

of

subprograms

using

the

criteria

of

coupling

and

cohesion

OO

the

focus

is

to

decide

where

to

physically

package

the

classes

and

objects

from

the

designs

logical

structure.

Modularity, Encapsulation, and Abstraction

The

principles

of

abstraction,

encapsulation,

and

modularity

are

synergistic

An

object

provides

a

crisp

boundary

around

a

single

abstractions

and

both

encapsulation

and

modularity

provide

barriers

around

the

abstraction

Hierarchy

Abstraction is good, but a system with many distinct abstractions becomes difficult to understand

In most systems, a set of abstractions will form a hierarchy - By identifying hierarchies in the design, we greatly reduce the complexity - We can say that a hierarchy is an ordering of abstractions

Example

Single inheritance

Multiple inheritance Employee Salary Hourly Executive Flowering plant Fruit Vegetable

Typing

Deriver from theories of abstract data types - The enforcement of the class of an object, such that objects of different types may not be interchanged, or at the most, they may be interchanged only in very restricted ways

Typing allows us to express abstractions so that the programming language on which we implement them can be made to enforce design decisions

Concurrency

Distinguishes

an

active

object

from

one

that

is

not

active

Persistence

The

property

of

an

object

which

its

existence

transcends

time

and

space.