Vous êtes sur la page 1sur 29

L2-Object Oriented

Programming (OOP)
JAVADr Vish Kallimani

Road map
Programming languages
Software Engineering
OOP
JAVA
Objects and Class

Paradigms of Programming Languages


The Paradigms of programming Language gives the
model to the programmer to write the programs.The different
Paradigms of programming languages are,

Unstructured Programming (or) Monolithic Programming


Procedural Programming
Structural Programming
Object Oriented Programming

Conventional Programming

Modular

programming

Top down programming


Bottom up programming
Structured programming
C is a structured program proved
powerful but failed for the larger program.

OOPS ( Object Oriented Program ) eliminate


some pitfalls of conventional programming.
Ex : Small Talk , C++ , JAVA.
4

Structured Programming (top-down programming)


in 1970s and into the 80s, the primary software
engineering methodology wasstructured programming.
To solve a large problem, break the problem into
several pieces and work on each piece separately;
To solve each piece, treat it as a new problem which
can itself be broken down into smaller problems;
eventually, you will work your way down to problems
that can be solved directly, without further
decomposition.
top-down design is often combined withbottom-up
design.

Bottom-up design
the approach is to start "at the bottom,"
with problems that you already know how
to solve
From there, you can work upwards towards
a solution to the overall problem

SOFTWARE ENGINEERING
PROGRAMS MUST BE DESIGNED.
The discipline calledsoftware engineeringis
concerned with the construction of correct, working,
well-written programs.
The software engineer tries to use accepted and
proven methods for analyzing the problem to be
solved and for designing a program to solve that
problem.

Object Oriented (OOP) Concepts

Modules that could support this kind of informationhiding became common in programming languages
in the early 1980s
Since then, a more advanced form of the same idea
has more or less taken over software engineering.
This approach is calledobject-oriented programming,
The central concept of object-oriented programming
is theobject, which is a kind of module containing
data and subroutines.
an object is a kind of self-sufficient entity that has an
internalstate(the data it contains) and that can
respond tomessages(calls to its subroutines).
9

The OOP approach to software engineering is to


start by identifying the objects involved in a
problem and the messages that those objects
should respond to.

The program that results is a collection of objects,


each with its own data and its own set of
responsibilities.

The objects interact by sending messages to each


other.
There is not much "top-down" in the large-scale
design of such a program, and people used to
more traditional programs can have a hard time
getting used to OOP.
10
object-oriented programs tend to be better models


In CRISP OOP :
To eliminate flaws of procedural approach.
Treats the data as a critical element & does not
allow it to flow freely around the system.
Allows to decompose a problem in to a no of
entities called objects and then build data and
functions ( Methods ) around these entities .
The combination of data and methods make up
an object.

11

(contd..)
Data structure are designed such that
they characterize the objects
Methods that operate on data of an
object are tied together in data structure.
Data is hidden and can not be accessed
by the external functions.
Objects may communicate with each
other through methods

12

Example:
Consider a drawing program that lets the user draw lines,
rectangles, ovals, polygons, and curves on the screen.
In the program, each visible object on the screen could be
represented by a software object in the program.
There would be five classes of objects in the program, one for
each type of visible object that can be drawn.
All the lines would belong to one class,
all the rectangles to another class, and so on.

DrawableObject, MultipointObject, and TwoPointObject would


be classes in the program.
MultipointObject and TwoPointObject would be subclasses of
DrawableObject.
13

OOP Concept mind map

14

Java is an Object Oriented Language.


As a language that has the Object
Oriented feature Java supports the
following fundamental concepts:
Objects and classes
Data Abstraction and Encapsulation
Instance
Method
Dynamic Binding
Inheritance
Polymorphism
Message Parsing
Message Communication

15

In Crisp
Class: Collection of objects is called class. It is a logical entity.
Inheritance: When one object acquires all the properties and behaviours of parent
object
Polymorphism: When one task is performed by different ways.
In java, we use method overloading and method overriding to achieve
polymorphism.
Abstraction: Hiding internal details and showing functionality is known as
abstraction.
For example: phone call, we don't know the internal processing.
In java, we use abstract class and interface to achieve abstraction.
Encapsulation: Binding (or wrapping) code and data together into a single unit is
known as encapsulation.
For example: capsule, it is wrapped with different medicines.
16

Features of Java:
Benefits of OOP

Quality Products
Lower maintenance cost.
Through Inheritance
redundant code can be
eliminated
Improves security due to
data hiding
Multiple objects can
coexist without
interference.
Can be easily updated
from small to large
programs.

Compiled and
interpreted
Platform independent
Object Oriented
Robust and secure
Distributed
Simple and small
Multi threaded and
interactive
High Performance
Dynamic and
extensible
Internet (server side
and browser side,
Real time Java
Mobile communications

Applications :
Real time systems, Internet , Simulation and

17

JAVA
either

Stand alone
applications

or

Web Applets
(Internet)

Java is Compiled and interpreted


Usually computer language is either compiled or
interpreted. Java combines both (two stage
system).
Stage 1:
Java compiler translates source code into bytecode
instructions. Byte codes are not machine
instructions
Stage 2:
Java interpreter generates machine code that can
18
be directly executed by the machine that is

Object
An Object may be a person, Place , Account ,user defined
data..
Objects have states and behaviors.
Each object contain code and data to manipulate
the data.
Objects can interact without knowing each others
code and data.

Example: A dog has states-color, name, breed as well as


behaviors -wagging, barking, eating. An object is an 19

20

INSTANCE
An object that belongs to a class is said to be an
instance of that class.
The variables that the object contains are called
instance variables.
The subroutines that the object contains are called
instance methods.

21

Instance variables :
Instance variables are declared in a class, but
outside a method, constructor or any block.
When a space is allocated for an object in the heap
a slot for each instance variable value is created.
Instance variables are created when an object is
created with the use of the key word 'new' and
destroyed when the object is destroyed.
Instance variables can be declared in class level
before or after use.
Access modifiers can be given for instance
variables.
The instance variables are visible for all methods,
constructors and block in the class.

CLASS
its a specification or a pattern which we define
and every object we define will follow that pattern.
What does Java Class Consist
When we create class in java the first step is
keyword class and then name of the class or
identifier we can say.
Next is class body which starts with curly braces
{} and between this all things related with that
class means their property and method will come
here.
23

CLASS is:
The entire set of data and code of an object can be
made a user defined type using the concept called the
class.
A class
Object

as a Data Type
as a variable type

Once class is created any no of objects can be


created belonging to that class.

A class is the collection of Objects of similar types.


Ex

: Class
Objects

Fruit,
: Mango , Apple , Orange .

What are members of Class?


Field: field is nothing but the property of the class or object which we are going to create.
Method: method is nothing but the operation that an object can perform it define the
behavior of object how an object can interact with outside world .startMethod (),
shutdownMethod ().
Access Level of members: Access level is nothing but where we can use that members
of the class.
Each field and method has an access level:
private: accessible only in this class
package or default: accessible only in this package
protected: accessible only in this package and in all subclasses of this class
public: accessible everywhere this class is available
static in java is used for memory management mainly. We can apply
java static keyword with variables, methods, blocks and nested class. The
static keyword belongs to the class than instance of the class.
The static can be:
variable (also known as class variable)
method (also known as class method)
block
nested class
25

CLASS
Template is:
Class (name of the class) {
(Here define member of class)
}

26

CLASS..
Consider a simple class whose job is to group
together a few static member variables. For
example, the following class could be used to store
information about the person who is using the
program:
class UserData {
static String name;
static int age;
}
In Java, no variable can ever hold an object.
A variable can only hold a reference to an
object.

27

28

Summary
Conventional programming and their limitations. OOP concepts

THANK YOU

29

Vous aimerez peut-être aussi