Saturday 22 November 2014

Main Components of Object Oriented Technology

When we learn the Object Oriented Programming using Java, we have the knowledge of main components:

  • Objects and Classes
  • Data Abstraction and Encapsulation
  • Inheritance
  • Polymorphism
These are the components of Object Oriented Technology. Let's understand a detailed description of the above component.

Objects

Let's start with an Object. The first thing that we should do in the Object Oriented approach is to start thinking in terms of Objects because in Object Oriented programming object is center point or we can say that the heart of OOP.

Definition: An object is a software bundle of variables and related methods.

Look around right now and you will find many real - world objects such as, your laptop, any dog, your television, your scooter bike, your mobile etc.
Real - world objects share two characteristics: they all have State and Behavior. so, we can think like,
My Dog (My Object) Dog have state (name, color, hungry) and behavior (barking, fetching, wagging tail).

Software Objects are conceptually similar to real world objects. they also consist of state and behavior. An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (function in some programming language).

Class

In the real world, you often have many objects of the same kind. For example, your dog is just one of many dogs in the world.  In object-oriented terminology, we say that your dog object is an instance of the class known as animal. Dogs have some state and behavior in common.

In object-oriented software, it is also possible to have many objects of the same kind that share characteristics.

Definition: A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.


Data abstraction and encapsulation

The wrapping up of data and functions into a single unit is known as encapsulation. This is one of the strong features of the object oriented approach. The data is not directly accessible to the outside world and only the functions, which are wrapped in the class, can access it. Functions are accessible to the outside world. These functions provide the interface to access data. If one wants to modify the data of an object, s/he should know exactly what functions are available to interact with it. This insulation of the data from direct access by the program is known as data hiding.

Abstraction refers to the act of representing essential features without including the background details to distinguish objects/ functions from other objects/functions. In case of structured programming, functional abstraction was provided by telling, which task is performed by function and hiding how that task is performed. A step further, in the Object Oriented approach, classes use the concept of data abstraction. With data abstraction, data structures can be used without having to be concerned about the exact details of implementation. As in case of built-in data types like integer, floating point, etc. The programmer only knows about the various operations which can be performed on these data types, but how these operations are carried out by the hardware or software is hidden from the programmer. Similarly in Object Oriented approach, classes act as abstract data types. Classes are defined as a set of attributes and functions to operate on these attributes. They encapsulate all the essential properties of the objects that are to be created.

Inheritance

Inheritance is the process by which objects of one class acquire the properties of objects of another class in the hierarchy. For example, the scooter is a type of the class two-wheelers, which is again a type of (or kind of) the class motor vehicles.

Definitions: A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or parent class).
Types of Inheritance

Polymorphism

Polymorphism means the ability to take more than one form of the same property. The dictionary definition of polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages. This principle can also be applied to object - oriented programming and languages like the Java language. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.


Polymorphism

Wednesday 15 October 2014

Concept OOP

Hey Guys,
You are familiar with Structured Programming Language.....
Now, We have new concept that is Object Oriented Programing Language i.e., OOP.

OOP is a Programming Paradigm that represent concept of 'Objects' that have 'Data Fields' (attributes that describe the object) and associated procedures known as Methods.

Now you have a Question i.e. , What is Paradigm?
The term paradigm describes a set of techniques, methods, theories and standards that together represent a way of thinking for problem solving. According to [Wegner, 1988], paradigms are “patterns of thought for problem solving”.

Language paradigms were associated with classes of languages. First the paradigms are defined. Thereafter, programming languages according to the different paradigms are classified. The language paradigms are divided into two parts, imperative and declarative paradigms as shown in the Figure.

  • Imperative languages: can be further classified into procedural and object oriented approach.
  • Declarative languages: can be classified into functional languages and logical languages.

Imperative paradigm: The meaning of imperative is “expressing a command or order”, so the programming languages in this category specify the step-by-step explanation of command.

Procedural paradigm: Procedural languages are statement oriented with the variables holding values. In this language the execution of a program is modeled as a series of states of variable locations.

Object Oriented paradigm: The Object Oriented paradigm is centered on the concept of the object. Everything is focused on objects.

Declarative paradigm: In this paradigm programs declare or specify what is to be computed without specifying how it is to be achieved. Declarative programming is also known as Value-oriented programming.

Functional paradigm: In this paradigm, a program consists of a collection of functions. A function just computes and returns a value.

Logic paradigm: In this paradigm programs only explain what is to be computed not how to compute it. Here program is represented by a set of relationships, between objects or property of objects known as predicate which are held to be true, and a set of logic/clauses (i.e. if A is true, then B is true). Basically logic paradigm integrates data and control structures.


Object Oriented Programming

Object Oriented Programming is a real world programming.

The world and its applications are not organized as functions and values separate from one another. The problem solvers do not think about the world in this manner. They always deal with their problems by concentrating on the objects, their characteristics and behavior.

The world is Object Oriented, and Object Oriented programming expresses programs in the ways that model how people perceive the world. there are many real world objects around us which we often used to performing different functions. such as, our compass box, fans etc. through this real world example we can understand that problem solving using OO approach  is very close to our real life problem solving techniques.

The major benefit of using OO approach is that the program is organized around the data being operated upon rather than the operations performed. The basic idea behind OOP is to combine both, data and its functions that operate on the data into a single unit called object.