Docsity

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

Partial preview of the text

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

CS

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

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/

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

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

Also known as information hiding

For abstraction to work, encapsulation must be present

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

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

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