01 what is oop, Study notes of Computer Networks

description of oops

Typology: Study notes

2014/2015

Uploaded on 02/26/2015

unknown user
unknown user 🇮🇳

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Amity School of Engineering
B.Tech., CSE(5th Sem.)
Java Programming
Topic: Object Oriented Programming
ANIL SAROLIYA
Amity School of Engineering & Technology
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download 01 what is oop and more Study notes Computer Networks in PDF only on Docsity!

Amity School of Engineering

B.Tech., CSE(5th^ Sem.)

Java Programming

Topic: Object Oriented Programming

ANIL SAROLIYA

Amity School of Engineering & Technology

Text/ Reference Books

 JAVA for Beginners, Joyce Farrell, CENGAGE Learning

 Java the complete Reference by Patrick Naughton & Herbert Schild, Tata

Mc-Graw Hill

 Java How to program, Deitel & Deitel, Pearson

 Head First Java, Kathy Siera & Bert Bates, O’Reilly Media

Amity School of Engineering & Technology

OOP Definition

“Object-oriented programming is a way of

implementation in which programs are

organized as cooperative collections of objects,

each of which represents an instance of some

class, and those classes(categories) are all

members of a hierarchy of classes united via

inheritance relationships.''

Amity School of Engineering & Technology

New Programming Paradigms Requirement

The cost of software development & maintenance is increasing substantially as compared to the cost of the hardware of a computing system, but hardware technology is improved.This increasing cost in software & technological improvement in hardware demands a cost effective & more technical compatible programming paradigm.Software maintenance is the process of modifying or extending the capabilities of the existing software.

5

  • An object is like a

black box.

  • It’s a material thing

that can be seen or

touched.

  • The internal details

of such things are

hidden.

OO Programming

  • Identifying objects and

assigning responsibilities

to these objects.

  • Objects communicate to

other objects by sending

messages.

  • Messages are received by

the methods of an object

Object

What is Object Oriented Programming?

  • Tangible Things as a car, printer, ...
  • Roles as employee, boss, ...
  • Incidents as flight, overflow, ...
  • Interactions as contract, sale, ...
  • Specifications as colour, shape, …

What is an object?

  • Modularity - large software projects can be split up in

smaller pieces.

  • Reusability - Programs can be assembled from pre-

written software components.

  • Extensibility - New software components can be

written or developed from existing ones.

Why do we care about objects?

Object = Data + Methods

or

An object has the responsibility to know and

the responsibility to do.

The two parts of an object

Features of OOP Contd…

 Encapsulation: It is a mechanism that associates the code and the data it

manipulates into a single unit and keeps them safe from external interference and

misuse. That’s why OOP is some how secure than other type of programming.

 Data Abstraction: The technique of creating new data types that are well

suited to an application or program known as data abstraction. It provides the

ability to create user-defined data types which is also known as abstract data

types (ADTs).

 Inheritance :

 It allows the extension and reuse of existing code without having to rewrite the code from scratch. Inheritance involves the creation of new classes (derived classes) from the existing ones (base classes).  It enabling the creation of a hierarchy of classes , which gives the name of relationship: like:  Parent Class & Child Class RelationshipBase Class & Derived Class RelationshipSuper Class & Sub Class Relationship  Two popular forms of inheritance are single and multiple inheritance. Single inheritance refers to deriving a class from a single base class (^13)

Features of OOP Contd…

 Multiple Inheritance : A class is derived from more than one base class is

known as multiple inheritance. C++ supports multiple inheritance, JAVA doesn't

 Polymorphism: It allows a single name or operator to be associated with

different operations depending on the type of data passed to it. It is normally

achieved by function overloading, operator overloading, and dynamic binding

(virtual functions)

 Persistence: The incident where the object (data) survives in the program

execution time and exists between executions of a program is known as

persistence. All database systems support persistence. In C++, this is not

supported. However, the user can build it explicitly using file streams in a

program. In Java it is possible.

 Delegation: It is an alternative to class inheritance. Delegation is a way of

making object composition as powerful as inheritance. In delegation, two

objects are involved in handling a request: a receiving object delegates

operations to its delegate. This is analogous to the child classes sending

requests to the parent classes.

 Genericity: Genericity is realized through function templates and class

templates.

Object Oriented Programming

Depending on the object features supported, the languages are classified into two categories:

**1. Object-Based Programming Languages

  1. Object-Oriented Programming Languages** Object-based language = Encapsulation + Object Identity(means Object Name) & Object-oriented language = Object based language features + Inheritance + Polymorphism

Features of OOPS

Improvement over the structured programming paradigm  Emphasis on data rather than algorithm Data abstraction is introduced in addition to procedural abstraction  Data and associated operations are unified into a single unit which is termed as Object Programs are designed around the data being operated, rather than operations themselves (data decomposition-rather than algorithmic decomposition) Relationships can be created between similar, yet distinct data types

 Examples: Java, C++, Smalltalk, Eiffel. etc.

Structured Versus Object-Oriented Programming

In structured programming or conventional programming or function oriented programming or procedural programming, data are defined as global data and access (or changes) by all the functions of a program without any restriction. Due to this data security and integrity has reduced

whereas,

OOPs, data is encapsulated with the

associated functions (or operations),

such encapsulated form or capsule is

called an object

Thanks

Amity School of Engineering & Technology B.Tech., CSE(5th Sem.)