Object-Oriented
Programming Concepts:-
An object is a software bundle of
related state and behavior. Software objects are often used to model the
real-world objects that you find in everyday life. This lesson explains how
state and behavior are represented within an object, introduces the concept of
data encapsulation, and explains the benefits of designing your software in
this manner.
Class
A class is a blueprint or prototype
from which objects are created. This section defines a class that models the
state and behavior of a real-world object. It intentionally focuses on the
basics, showing how even a simple class can cleanly model state and behavior.
Inheritance
Inheritance provides a powerful and
natural mechanism for organizing and structuring your software. This section
explains how classes inherit state and behavior from their superclasses, and
explains how to derive one class from another using the simple syntax provided
by the Java programming language.
Interface
An interface is a contract between a
class and the outside world. When a class implements an interface, it promises
to provide the behavior published by that interface. This section defines a
simple interface and explains the necessary changes for any class that
implements it.
Package
A package is a namespace for
organizing classes and interfaces in a logical manner. Placing your code into
packages makes large software projects easier to manage. This section explains
why this is useful, and introduces you to the Application Programming Interface
(API) provided by the Java platform.
Principles of OOP:-
In order for a programming language to be object-oriented, it has to enable working with classes and objects as well as the implementation and use of the fundamental object-oriented principles and concepts: inheritance, abstraction, encapsulation and polymorphism. Let’s summarize each of these fundamental principles of OOP:
- Encapsulation
We will learn to hide unnecessary details in our classes and provide a clear and simple interface for working with them.
- Inheritance
We will explain how class hierarchies improve code readability and enable the reuse of functionality.
- Abstraction
We will learn how to work through abstractions: to deal with objects considering their important characteristics and ignore all other details.
- Polymorphism
We will explain how to work in the same manner with different objects, which define a specific implementation of some abstract behavior.
Need for Object Oriented Programming:-
When we are going to work with classes and objects we always think why there is need of classes and object although without classes and objects our code works well. But after some work on classes and objects we think, yeah its better to work with classes and objects .And then we can understand that Object oriented Programming is better than procedural Programming.
Object oriented programming requires a different way of thinking about how can we construct our application.
Lets take a short example:
When we are going to build a house .We distribute the works needed to make a house we can divide the works in different part and deliver to different persons like plumber for water supply, electrician for electricity etc. The electrician doesn’t need to know that the work of plumber and vice versa.
In the same way in Object Oriented Programming we can divide our applications in different modules called classes .And one class is separate from other classes .It has its own functionality and features.
So what advantages we can get from Object Oriented Programming:
1: Re-usability Of Code: In object oriented programming one class can easily copied to another application if we want to use its functionality
e.g. When we work with hospital application and railway reservation application .In both application we need person class so we have to write only one time the person class and it can easily use in other application.
2: Easily Discover a bug: When we work with procedural programming it take a lot of time to discover a bug and resolve it .But in object Oriented Programming due to modularity of classes we can easily discover the bug and we have to change in one class only and this change make in all the application only by changing it one class only.
3: Object- Oriented Programming enables us to easily model our applications based on the real world which help us to easily identify the requirements, what code is to be written and how different classes interact with each other which have same properties and behaviors.
Types of Java Applications:
There are mainly 4 type of applications that can be created using java programming:
1) Standalone Application: It is also known as desktop application or window-based application. An application that we need to install on every machine such as media player, antivirus etc. AWT and Swing are used in java for creating standalone applications.
2) Web Application: An application that runs on the server side and creates dynamic page, is called web application. Currently, servlet, jsp, struts, jsf etc. technologies are used for creating web applications in java.
3) Enterprise Application: An application that is distributed in nature, such as banking applications etc. It has the advantage of high level security, load balancing and clustering. In java, EJB is used for creating enterprise applications.
4) Mobile Application: An application that is created for mobile devices. Currently Android and Java ME are used for creating mobile applications.
Procedural vs Object Oriented Programming:-
Procedural vs Object Oriented Programming:-
Procedure Oriented Programming
|
Object Oriented Programming
| |
Divided Into
|
In POP, program is divided into small parts called functions.
|
In OOP, program is divided into parts called objects.
|
Importance
|
In POP,Importance is not given to data but to functions as well as sequence of actions to be done.
|
In OOP, Importance is given to the data rather than procedures or functions because it works as a real world.
|
Approach
|
POP follows Top Down approach.
|
OOP follows Bottom Up approach.
|
Access Specifiers
|
POP does not have any access specifier.
|
OOP has access specifiers named Public, Private, Protected, etc.
|
Data Moving
|
In POP, Data can move freely from function to function in the system.
|
In OOP, objects can move and communicate with each other through member functions.
|
Expansion
|
To add new data and function in POP is not so easy.
|
OOP provides an easy way to add new data and function.
|
Data Access
|
In POP, Most function uses Global data for sharing that can be accessed freely from function to function in the system.
|
In OOP, data cannot move easily from function to function,it can be kept public or private so we can control the access of data.
|
Data Hiding
|
POP does not have any proper way for hiding data so it is less secure.
|
OOP provides Data Hiding so provides more security.
|
Overloading
|
In POP, Overloading is not possible.
|
In OOP, overloading is possible in the form of Function Overloading and Operator Overloading.
|
Examples
|
Example of POP are : C, VB, FORTRAN, Pascal.
|
Example of OOP are : C++, JAVA, VB.NET, C#.NET
|
No comments:
Post a Comment