Originally posted by Vishal Vohra:
As the first part of the definition details about "reducing and factoring about details" - how is this achieved in JAVA.
Take a look at this code:
In that code, Java has totally abstracted the file system from me. I can very easily determine if a file exists. Without Java's abstraction, I would need to know how to do that on every possible OS that Java runs on. Then in turn the OS' I/O functions abstract me (and Java) from knowing how to communicate with the different I/O drivers (CD ROM. tape drive, hard disk, USB memory stick, etc). The hard disk driver then abstracts the file access. The OS (and I) doesn't need to know how to send the right electrical signal to the hard drive to tell it to start spinning. Oh, and that varies for every possible hard drive models on the market (thousands of them). Then what electrical signal to send to move the drive head. Then what signal to send to find the file in question. etc, etc.
Each layer (Java --> JRE --> OS --> Motherboard Bus--> Hard Disk Drivers --> disk drive --> magnetic charges on drive patter) abstracts the complexity from the next layer. And in the end, in one simple line of code I can determine if a File exists. Thanks to Java's File abstraction, I don't need to know about the specifics of hard drives.
This is just one example of abstraction; more specific to the idea of reduced complexity and removal of details.
Even the "File object" or the term "File" is a type of abstraction. An electronic device (i.e. the hard drive) does not have manila folders on it. It doesn't have pieces of paper. It just has magnetically charged particles. We refer to a group of those particles that are related and represent last month's accounting report as "a file". That's an abstraction.
I think the car example in
Garrett's reply in the
thread I referenced above is a good example/explanation of this concept as well.
Originally posted by Vishal Vohra:
Secondly, according to the second part of the definition does Abstraction means defining classes.
I found these definitions almost everywhere, so does abstraction really mean hiding implementation details and if it does, then does it also brings out the concept of interfaces and abstract classes which only provides method signatures and hide out the actual implementation from the end user.
I think others have answered this, so I won't say much more that to echo the point that there are many different types of abstraction. The point you are asking about here is are classes abstractions. A "Person" class is an abstraction in that it is not really a living person (obviously). It is a programing construct used to represent a person (i.e. an abstraction). In an employee benefits program that abstraction will be very different than in a medical records application, which will be different than a X-Ray machine's internal code.
As mentioned, there are many different types and levels of abstraction. But it is a key concept. So kudos to you for working through it and asking questions. Keep asking until you understand it well. It will pay great dividends in the end.
[ August 21, 2008: Message edited by: Mark Vedder ]