Results 1 to 5 of 5

Thread: Abstraction

  1. #1
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

    Default Abstraction

    Hi all,

    Can anyone give me a simple example code of abstraction as am facing difficulty in understanding its concept theoretically. Visited a site which said abstraction was nothing but data hiding. If thts abstraction then what makes encapsulation different from it???

    Thank you

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,353
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by maya700 View Post
    Hi all,

    Can anyone give me a simple example code of abstraction as am facing difficulty in understanding its concept theoretically. Visited a site which said abstraction was nothing but data hiding. If thts abstraction then what makes encapsulation different from it???

    Thank you
    Abstraction is more than hiding of data; it can also hide behaviour. Think of Lists; they are Iterable. All you know of an Iterable (an interface) is that it can give you an Iterator (also an interface). Hopping from one element to the next in an array (ArrayList) is quite different than hopping from one element to the next over a linked list (LinkedList). The behaviour is hidden from you by the iterator which was created by the Iterable. The actual behaviour is abstracted away from you.

    kind regards,

    Jos

  3. #3
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

    Default

    okay you mean to say that by abstraction we dont care about the behavior, we just use the functionality.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,353
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by maya700 View Post
    okay you mean to say that by abstraction we dont care about the behavior, we just use the functionality.
    Yes, abstraction is more about common functionality (Iterables and Iterators) while data hiding is more about data security and putting the responsibility for that data where it belongs. Together the two define encapsulation, not only for data but also for behaviour.

    Inheritance can also be used for abstraction: a superclass defines the common behaviour and the subclasses (can) inherit the behaviour. The same goes with the data. Inheritance does create a tight coupling between the classes while interface implementation (Iterables and Iterators again) does not.

    kind regards,

    Jos

  5. #5
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

Similar Threads

  1. diff between abstraction and inheritance
    By sandeepsai17 in forum New To Java
    Replies: 4
    Last Post: 05-24-2010, 06:04 AM
  2. Abstraction
    By anurag in forum New To Java
    Replies: 6
    Last Post: 05-15-2010, 06:15 PM
  3. [SOLVED] Abstraction: Pillar of OOP?
    By leiferouis in forum New To Java
    Replies: 7
    Last Post: 01-31-2009, 08:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •