seminar on oops

advertisement
22-Mar-16
www.fakengineer.com

INTRODUCTION.
 FEATURES OF OOP.
 ORGANIZATION OF DATA & FUNCTION
IN OOP.
 OOP’S DESIGN.
 DESIGN OF MEMBER FUNCTION.
 ANALISYS OF OOP.
 BENEFITS OF OOP.
22-Mar-16
www.fakengineer.com
INTRODUCTION
22-Mar-16
www.fakengineer.com
Object-oriented programming (OOP) now dominates the
procedural-programming paradigm in many application
areas. Developers often choose OOP and scripting
languages—such as C++, Java for project implementations
because these languages provide a way to form
appropriately realistic models of real systems and processes.
Actually, avoiding OOP technology may produce less-thanoptimal designs and deny the development team the
opportunity to code in a more intuitive fashion. Here's a list
of some of the most interesting topics in OOP development:
What is OOPs?
Object-Oriented programming as an approach that
provide s a way of modularizing programs by
creating partititioned memory area for both data
and functions that can be used as templates for
creating copies of such modules on demands.
22-Mar-16
www.fakengineer.com
ORGANISATION OF DATA AND
FUNCTION IN OOP’S:
The major motivating factor in the invention of object
oriented approach is to remove some of the flows
encountered in the procedure approach. OOP treats data as a
critical element in the program development and does not
allow it to flow freely around the system.
Object A
Object B
Data
Functions
Data
Communication
Object C
Functions
22-Mar-16
Data
www.fakengineer.com
Functions
Some of the striking features of OOP are:
Programs
are divided into what are know as objects.
Functions that operate on the data of an object are tied
together in the Data Structure.
 Data is hidden and cannot be accessed by external
functions.
 Objects may communicate with each other through
functions.
 New data and functions can be easily added whenever
necessary.
 Follows bottom-up approach in program design.
22-Mar-16
www.fakengineer.com
BASIC CONCEPT OF OOP’S
It is necessary to understand some of the concepts
used extensively in OOP.
 Object .
 Classes.
 Data Abstraction and Encapsulation.
 Inheritance.
 Polymorphism.
 Dynamic Binding.
Message Communication.
www.fakengineer.com
22-Mar-16
OBJECT: Objects are the basic run-time entities in an Object
-Oriented System.They may represent a person, a place, a bank
account or any item that the program has to handle.
When a program is executed, the objects interact by
sending messages to one another.
CLASSES:A class is thus a collections of objects of similar
type. For example, mango, apple,and orange are members of
the class fruit. Class are user-defined data type and behave like
the built-in type of a programming language.
If fruit has been
defined as a class, then the statement
fruit mango;
Will create and object mango belonging to the fruit.
22-Mar-16
www.fakengineer.com
DATA ABSTRACTION & ENCAPSULATION
The wrapping up of data and functions into a single unit (called
class) is known as encapsulation. Data Encapsulation is the most
striking feature of a class. The data is not accessible to the
outside world, and only those functions which are wrapped in the
class can access it. These functions provide the interface between
the objects data and the program. This insulation of the data from
direct access by the program is called data hiding or information
hiding.
Since the classes use the concept of data abstraction, they are
known as Abstract Data Type(ADT).
22-Mar-16
www.fakengineer.com
INHERITANCE: Inheritance is the process by which
object of one class acquire the properties of object of
another class. It supports the concept of hierarchical
classification.
Bird
Attribute
…………..
Flying Bird
Non flying Bird
Attributes
…………
Attributes
…………..
Parrot
Attributes
………….
22-Mar-16
Pigeon
Penguin
Attributes
Attributes
………….
………….
www.fakengineer.com
Kiwi
Attributes
………….
ANOTHER EXAMPLE
Student
Attribute
…………..
Girls
Boys
Attributes
…………..
Attributes
…………
Bishnu
Attributes
………….
Ramesh
Attributes
………….
Sumitra
Attributes
………….
Basanti
Attributes
………….
POLYMORPHISM:Polymorphism is another
important OOP’s concept. Polymorphism, a Greek
term, means the ability to take more than one form. An
operation may take exhibit different behaviors in
different instances.
The process of making an operator to exhibit different
behaviors in different instance is known as operator
overloading.
Using a single function name to perform different
types of tasks is known as function overloading.
22-Mar-16
www.fakengineer.com
Shape
Draw( )
Circle Object
Draw (Circle)
22-Mar-16
Box Object
Draw (Box)
Function
over loading
www.fakengineer.com
Triangle Object
Draw (Triangle)
DYNAMIC BINDING:
Binding refers to the linking of procedure call to the
code to be executed in response to the call. Dynamic
binding (Also known as late binding) means that the
code associated with a given procedure call is
unknown until the time of call at run-time.
It is associated with polymorphism.
22-Mar-16
www.fakengineer.com
Message communications:
An object-oriented program consists of a set of
object that communicate with each other.
It involves three steps

creating classes that defined objects.

creating objects from class definition.

Establishing communication among objects.
22-Mar-16
www.fakengineer.com
Object 1
Object 2
Object 5
Object 4
Object 3
www.fakengineer.com
22-Mar-16
Network of objects
communicating between them.
STEPS IN OBJECT-ORIENTED DESIGN:
1.
2.
3.
4.
Design is concerned with the mapping of objects in the
problem space into objects in the solution space, and
creating an overall structure and computational model
of the system. The object oriented design(OOD)
approach may involve the following steps.
A review of object created in the analysis phase.
Specification of class dependencies.
Organization of class hierarchies.
Design of class.
22-Mar-16
www.fakengineer.com
1.Review of Problem Space Objects:



An exercise to review the objects identified in the
problem space is undertaken as a first step in the
design stage. Some guidelines that might help the
review process are:
If only one object is necessary for a service (or
operation), then it operates only on that object.
If two or more objects are required for an operation to
occur, then it is necessary to identify which object’s
private part should be known to the operation.
If an operation requires knowledge of more than one
type of objects, then the operation is not functionally
cohesive and should be rejected.
22-Mar-16
www.fakengineer.com
2.Class Dependencies:
Analysis of relationships between the classes is
central to the structure of a system. Therefore, it is
important to identify appropriate classes to represent the
objects in the solution space and establish their
relationships. The major relationships that are important in
the context of design are:
Inheritance relationships.
Containment relationships.
Use relationships.
22-Mar-16
www.fakengineer.com
3.Organization Of Class Hierarchies:
Organization in the class hierarchy involve
identifications, attributes and functions among a
group of related classes and the combining them to
form a new class. A new class will serve as the
super class and the other as subordinate classes,
The new class may or may not have the meaning of
an object by itself. If the object is created purely to
combine the common attributes it is called an
abstract class.
22-Mar-16
www.fakengineer.com
A
B
C
D
E
(a) Objects in solution spaces
X
A
Y
B
C
(b) First level of hierarchy
D
E
Z
X
A
Y
B
C
D
(c) Second level of hierarchy
E
4.Design of Class
We have identified classes, their attributes, an minimal set of
operations required by the concept a class is representing. We
must look at the complete details the each classes represents.
The important issue is to decide word functions are to be
provided.
Some guidelines of designing of class:
 The public interface of a class should have only functions of
the class.
 An object of one class should not send a message directly to
a member of another class.
 A class should dependent on as few classes as possible.
www.fakengineer.com
 Interaction
between two
classes must be explicit.
22-Mar-16
DESIGN OF MEMBER FUCNTION:
We have to identified.
 Class and object.
 Data member function.
 Interface.
 Dependencies and .
 Class hierarchy.
22-Mar-16
www.fakengineer.com
BENEFIT OF OOP:
Object-orientation contributes to the solution of many
problems associated with the development and quality of
software products. The principal advantages are
 Through inheritance we can eleminate redundant code
and extend the use of existing.
 Classes .
 The principle of data hiding helps the programmer to
built secure that can not be invaded by code in other part
of the program.
 Object-oriented system can be easily upgraded from
small to large system.
 Software complexitywww.fakengineer.com
can be easily managed .
22-Mar-16
Download