Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to apply the concept of Abstraction in a java program?  RSS feed

 
Eshan Kapoor
Ranch Hand
Posts: 39
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to know how do we use abstraction while writing a program. Abstraction is hiding the implementation details and exposing only the necessary details. Like we don't know the complex and internal working of a Car that happens behind the scene when we drive it but we do know how to drive it, apply brakes etc.. Keeping this concept in mind, how can we apply it in a program?


Thanks

 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some searching of the Internets would have answered this question for you. For example:
http://en.wikipedia.org/wiki/Abstraction_(computer_science) - It even has examples.
 
maxim markin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You a bit misuse the terms
hiding the implementation details and exposing only the necessary details
it's not an abstraction it's a Encapsulation.
 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maxim markin wrote:it's not an abstraction it's a Encapsulation.

You sure about that?
 
maxim markin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
http://en.wikipedia.org/wiki/Encapsulation_%28object-oriented_programming%29

key word is "As information hiding mechanism"
 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose for the specific sentence you've quoted it's wooly enough that it could be argued either way. It uses the word "details", which could mean implementation (Abstraction) or it could mean state or data (Encapsulation).

However, in the context of the full paragraph giving the example of the controls of a Car, that is a higher level Abstraction from the internal workings of a Car which can be applied to other vehicle types, a Van, a Lorry, a Bumper Car, a Monster Truck, etc etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!