Object Oriented Programming Development

processroguishSoftware and s/w Development

Nov 18, 2013 (3 years and 11 months ago)

119 views

Object Oriented Programming

Development


By:

N.SATHISH KUMAR

CSE/LECTURER

SKREC


SOURCE:

WWW.NSKINFO.COM


Room:


A206

1a) What is an Object?


It is a combination of data & logic that
represents some real world entity, either
physical, conceptual, or software



Physical entity (e.g.) car



Conceptual entity (e.g.) chemical process


Software entity (e.g.) linked lis


An object is represented as rectangles
with underlined names


1b) Representing Objects

:
Professor

Professor Nandhini

ProfessorNandhini:

Professor

ProfessorNandhini


Object Name Only

Class and Object Name

Class Name Only

2a) What is a Class?


A class is a set of objects with common
properties (attributes), behavior (operations),
and relationships



-

An object is an instance of a class



A class is represented using a
compartmented rectangle


2b) Representing Classes

Professor

Professor Rani

a + b = 10

2c) Class Compartments


A class is comprised of three sections


The first section contains the class name


The second section shows the structure
(attributes)


The third section shows the behavior
(operations)


Professor

name

empID

create( )

save( )

delete( )

change( )

Class Name

Attributes

Operations


Objects are grouped into classes

2d)The Relationship Between
Classes and Objects

Objects

Professor Smith

Professor Jones

Professor Mellon

Class

Professor

5a) Inheritance


It allows objects to be built from other
objects.


It is a relational ship between classes.
(one class is the parent of other (
derived
)
class.


The parent class is also known as the
base class

(or)
super class
.

Account

balance

name

number

Withdraw()

CreateStatement()

Checking

Withdraw()

Savings

GetInterest()

Withdraw()

Superclass
(parent)

Subclasses

Generalization
Relationship

Ancestor

Descendents

5b) Example: Single Inheritance


One class inherits from another

5c) Multiple Inheritance


Some OO systems permit a class to inherit its
state (attributes) and behaviors from more than
one super class.

Vehicle

Car

Bus

Truck

Utility Vehicle


Define its behavior (what an object is
capable of doing).


CourseOffering

addStudent

deleteStudent

getStartTime

getEndTime


Class

Operation

4) What is method (or) procedure?

Basic Terminology:

Behaviour and Messages


The most important aspect of an object is
its
behaviour

(the things it can do). A
behaviour is initiated by sending a
message
to the object (usually by calling a
method).

Basic Terminology


Abstraction

is the representation of the
essential features of an object. These are
‘encapsulated’ into an
abstract data type.


Encapsulation
is the practice of including in
an object everything it needs hidden from
other objects. The internal state is usually
not accessible by other objects.


Basic Terminology:

Polymorphism


Polymorphism means “having many
forms”. It allows different objects to
respond to the same message in different
ways, the response specific to the type of
the object.

E.g. the message
displayDetails()
of the
Person class should give different results
when send to a Student object (e.g. the
enrolment number).

Appendix: Object
-
Oriented Concepts

Methods and messages

Method
:
Defines behavior of an object, as a set of encapsulated
functions.

Message:
Request from one object to another asking second
object to execute one of its methods.






(a)

(b)

(a) Object showing atts and methods

(b) Example of a method

Appendix: Object
-
Oriented Concepts

Classes

Class
: Blueprint for defining a set of similar objects.




-
Objects in a class are called

instances
.


-
Class is also an object with own

class attributes

and
class methods
.


Appendix: Object
-
Oriented Concepts

Polymorphism and dynamic
binding


Dynamic Binding:

Runtime process of selecting appropriate method
based on an object’s type.


Example:

With list consisting of an arbitrary no. of objects from the Staff hierarchy,
we can write:


list[i]. print


and runtime system will determine which print() method to invoke depending on
the object’s (sub)type.

Abstraction


One of the chief advantages of object
-
oriented programming is the idea that
programmers can essentially focus on the
“big picture” and ignore specific details
regarding the inner
-
workings of an object.
This concept is called
abstraction
.

Instantiation


To create an object based on a class, we
create an
instance
of that class. This
process is called instantiation.


In Java, JavaScript and other languages,
we use a special method called a
constructor method

to create an instance
of an object.


What

is Object
-
Orientation?

-

What is Object
?



An "object" is anything to which a concept applies,
in our awareness


Things drawn from the problem domain or solution space.


E.g., a living person in the problem domain, a software component in the solution space.




A structure that has identity and properties and behavior


It is an instance of a collective concept, i.e., a
class
.

Encapsulation

a.k.a. information hiding


Objects encapsulate:


property



behavior as a collection of methods invoked by

messages



state as a collection of instance variables


Abstraction

Focus on the essential

Omits tremendous amount of details

…Focus on what an object “is and does”


What

is Object
-
Orientation

-

Abstraction and Encapsulation

What is Object
-
Orientation

-

Another Example of Abstraction and Encapsulation

Class

Car



Attributes



Model



Location



#Wheels = 4


Operations



Start



Accelerate

<<instanceOf>>

<<instanceOf>>

<<instanceOf>>

What is generalization?

What is over
-
generalization??

Forall x [Car(x)
-
> …]

What is Object
-
Orientation?

-

Class


What is
CLASS
?


a collection of objects that share common properties, attributes, behavior and
semantics, in general.


What are all these???



A collection of objects with the same data structure (attributes, state variables)
and behavior (function/code/operations) in the solution space.



Classification


Grouping of common objects into a class


Instantiation
.


The act of creating an instance
.

Class

Car

Attributes



Model



Location



#Wheels = 4

Operations



Start



Accelerate

<<instanceOf>>

<<instanceOf>>

<<instanceOf>>