Hi i jut wanted to know that is the any specific difference between Abstraction and Encapsulation.Also is Abstraction the concept related to just OOPs or its a generic term.
views:
60answers:
1Abstraction is the more... abstract term here.
Encapsulation can be seen as one example of abstraction, where implementation details are omitted. But abstraction as a concept is certainly not limited to OOP; or even, for that matter, programming. Abstraction is really about forming higher-order concepts which connect seemingly unrelated concrete notions. It's the logical principle of leaving out details which are irrelevant to an idea, and capturing only what is essential to it.
I think the best example of abstraction that everyone is familiar with is numbers. What does the idea "3" mean? It could mean 3 cows, or 3 space ships, or 3 dreams. These are all unrelated things, yet there is something they have in common; the essential thing they have in common is that there are 3 of each of them. So "3" is an abstract concept which forgets the particulars of the things it is quantifying.
Similarly in programming, parametric polymorphism allows us to abstract away, for example, the type of the contents of a list. So a List<A>
doesn't care if it is a list of cows, space ships or dreams, as long as we pick one type of things and stick with it.