OOPS Pillars and Concepts:
There are 4 pillars of OOPs (along with class & object):
1. Encapsulation
2. Inheritance
3. Abstraction
4. Polymorphism
Important Terms in OOPS:
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
- Association
- Aggregation
- Composition
- Coupling
- Cohesion
- Generalization
- Realization
- Class and Object
1. What is Encapsulation?
Binding of data into single entity is called as Encapsulation. Please click on this Link for more details of Encapsulation.
2. Inheritance (IS-A):
Extends sub class from super class. The main advantage/use of IS-A relationship is Code Re-usability. Please click on this Link for more details of Inheritance in Java.3. Polymorphism:
Different behavior at different instance by using same entity is called as Polymorphism.
Eg. I am acting as software developer in office and acting as son at home. So here there are my 2 behaviors software developer and son at 2 different places ie. at Office and home by respectively by using same entity (here I am acting as an entity)
Please click on this Link for more details of Polymorphism in Java.4. Abstraction:
One of the pillar in object oriented programming. Exploring only required things to user.
E.g. ATM GUI Screen. We can see all options to check balance, withdraw money etc but can’t see code behind that. This shows that it will explore only required thing to user not internal implementations.
Please click on this Link for more details of Abstraction in Java.
5. Association:
Association set up the relationship between two different classes via their objects.
Relationship can be 1-1, 1-M, M-1, M-M.E.g. one student has many mobile numbers.
6. Aggregation (HAS-A):
It is special case of association, there is no specific keyword to implement HAS-A relation but most of the time we are depending on new keyword.
E.g. Department in a college consist of some professors, without existing department there may be a chance of existing professor object. Hence department and professor both objects are weakly associated & this weak association is called as aggregation.
7. Composition:
Composition is a restricted form of aggregation in which two entities (or class) are highly dependent on each other.
E.g. Human and heart, heart class has no sense if human class is not present.
8. Coupling:
Coupling refers to the degree of direct knowledge that on element has of another.
In other words we can say that how the changes in class A force related to changes in class B.
9. Cohesion:
Cohesion is refers to all about how a class is designed. Cohesion is object oriented principle most closely associated with making sure that a class is designed with a single, well focused purpose.
10. Generalization:
Eg. Let class person is exist, a student is a person, a faculty is person hence here the relationship between student and person similarly faculty and person is called as generalization.
11. Realization:
Realization is a relationship between class & the object containing its respective implementation level details. OR The relationship between interface & the implementing class.
12. Class and Objects:
Class are blueprints imaginary thing where objects are real time which provide an implementation to class.
Eg. Carpenter makes design to prepare a table of wood.
So here design of table is Class and Woods are objects which provide an actual implementations.
let's consider below example too. First class has been designed i.e. blueprint/design of building. Then implementation is done with help of objects (i.e. here building raw materials)
Blueprint of building (Class) |
Implementation of building (Objects) |
No comments:
Post a Comment
**** Please let me know if you have any doubts. ****