Category Archives: OOPS

About OOP for beginners


While you developing an application, application is subjected to change in its business logic’s as a result code will keep changing, so  Easy of use and avoid large chunk of code by eliminating duplication of code , OOP comes into picture.

Reason to use OOP

1) Complex code easier to develop.
2) OOP is exposing only required data, modularity, sharing, easy to maintain, controlling data accessibility.

Approach to Object Oriented Design:

1. Start with the simple object which can be abstracted into individual classes.
2. Identify all the classes in the requirement specification.
3. Identify the commonalities between all or small groups of classes. Do not force fit generalisation where it doesn’t make sense.
4. Keep all the data members private or protected.
5. Identify all the member variables and methods the class should have.
6. Ensure that the class is fully independent of other classes and contains all the necessary attributes and methods.
7. The methods in the class should be abstract.
8. Don’t use the procedural code into a class for the methods in the class.
9. Inherit and extend classes from the base classes when require.
10. Define the “Has-A” or “Uses-A” relationships among the classes

OOP Concepts

Image Source from Google

1) Class
Class is a blue print which is containing only list of variables and method and no memory is allocated for them. A class is a group of objects that has common properties.

2) Object
Objects are usable instances of class. In otherwords Object is the physical as well as logical entity where as class is the only logical entity.

Note:- objects are usable instances of class
Example: Student obj=new Student();
* Here obj is the instance of class Student and ‘new Student()’ is way to create an object
* A new object has been created in memory and it reference has been returned (new Student())
* Holding the object reference in a variable called instance(obj=new Student())

3) Abstraction
Abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user.

4) Encapsulation
Encapsulation is a mechanism of wrapping the data (instance variables) and code acting on the data (methods) together as a single unit like a Class.
The variables of a class can be made hidden from other classes, and can be accessed only through the methods of their current class. It is also known as data hiding.

5) Inheritance
Saves time by acquiring the same object into another
The process where one class acquires the members of (methods and properties) of another.

6) Polymorphism
This is the ability of an object to perform in a wide variety of ways.

Will see in detail with example in up coming post

%d bloggers like this: