Results 1 to 8 of 8
  1. #1
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default [SOLVED] Abstraction: Pillar of OOP?

    I've been recently learning and doing assignments on the 4 pillars of OOP in java. I've searched around the internet for some research and I've obtained a solid understanding for inheritance, polymorphism and encapsulation. However, I cannot find anything I've been able to understand on abstraction. Most sources never even mention abstraction. Any explanations for this will be appreciated.

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    448
    Rep Power
    6

    Default

    Though Abstaction is not a widely used oops concept,Java professional has to know about it?
    Abstract is used to Create a root class.
    From the abstract class we will be able to derive class as we want.
    The important thing about abstraction is that it could not be intialized .

    For more to know about .visit java.sun.com
    Mak
    (Living @ Virtual World)

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    I don't have formal C.S. training, but what abstraction means to me is the process of identifying "core" aspects of objects and processes. This allows creating base classes that expose methods and properties dealing with the core aspects while concealing the details, which are implemented in extending or even auxiliary classes.

    For example, when I display an image in a Swing application, I could care less what "kind" of image it is: png, gif, jpeg, etc. Image is an abstraction of specific types of image files.

    Another example is a database connection. I don't care how the driver talks to the database, I just want a connection. Every database vendor has their own drivers, but I don't know the first thing about them. I just deal with the "connection" they provide

    Here's a Wikipedia article. It's a little too abstract for me ;-), but I don't have to turn in an assignment...
    Last edited by Steve11235; 01-30-2009 at 06:06 PM. Reason: typo 67890

  4. #4
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default Java 'Philosophy'

    Many things that are in Java do not make a lot of sense
    if you have learned to program in another language already.

    Java is quite advanced, and its compiler oversees a program
    in the style of a project manager.

    View the abstract class this way:

    You are working with a team of programmers. Certain
    specifications on the project are handed down to the
    programmers, who study them, then work to make the
    project come together.

    Rather than have a project engineer bring everyone
    together to 'discuss' changes to the project, or
    maybe send out a memo, you are given "Abstract classes"
    of which you are to extend, or expect to find your
    fellow programmers extending into objects that can be
    instanciated.

    If you show ignorance of this policy, expect to become
    unemployed shortly.

    As a solitary programmer working on your own home brewed
    project, you probably won't decide that an Abstract class
    is needed. Its purpose is to get a group of programmers
    'on the same page' so to speak, to get everyone conforming
    to the dictates from above.

  5. #5
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default

    Abstraction sounds a lot like polymorphism: taking out details from a detailed class. I am still kind of confused on this. If its not too much trouble can anyone give an example simple class?

  6. #6
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    The Number class is abstract, the Integer class extends it. take a peak at the java src, its really helpful. for me, i just get use to using it w/o worrying about the terminologies.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  7. #7
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Keep in mind, there is a difference between abstraction and abstract classes. "abstract" on a class simply means that the class is not fully implemented and must be extended, with all the "abstract" methods implemented, before it can be instantiated.

    Abstraction is a concept that is closely linked to polymorphism and inheritance.

    The best real-world example I use is ImageIcon. The simplest constructor accepts a file name. It figures out what kind of file it is dealing with and loads the data. Usually, I just want to display the image, so I set the ImageIcon as the property of a JLabel, and it displays. The name is misleading, it handles any size image.

    I know nothing of the underlying image data formats or about how the image gets displayed. All those details are dealt with out of my view; all I see is the abstract concept of a displayable image.

    I use abstract classes extensively when constructing frameworks. A framework provides most of the functionality of a full application. I created one that handled everything from JSP forms and the related HTML, CSS, and Javascript, to stored procedures in the database. When I went to create an application using the framework, I had to write less than 10% of the code; the rest was already in the framework.

    Abstract classes allow me to control how the framework is used, by forcing the developer to implement certain methods and by preventing them from changing others. The abstract class contains 90% of the code, the extending class only has code dealing with the specific data handled by that class.

  8. #8
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default

    Thanks for all the help guys. I think I have a firm understanding of these concepts now. Unfortunately I just found out today that the report was only formative (not needed to be handed in) and 2 other programs are dued instead.

Posting Permissions

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