Java classes and inheritance

Discussion in 'Java' started by abilonds, Sep 23, 2011.

  1. abilonds

    abilonds New Member

    Joined:
    Sep 23, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi Go4Expert o/.
    I already introduced myself here, but, I lost my account abilondias, and here I am to shot up a question.

    I am developing a Java Web application and need some instructions. There are 4 classes : Functionary, Donor, Receiver and Manager. All of them have almost the same atributtes. Should I use Java Inheritance or make a class for each one.

    *I think It would cause some pain when making the database and the setting the values on the Superclass and the childs.

    Abilon Dias
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    The one that is more logical is what you should be doing. If you think all those class derive common functionality from some Parent class, you should use inheritance.
     
  3. ewaldhorn

    ewaldhorn New Member

    Joined:
    Feb 16, 2010
    Messages:
    36
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    Cape Town, South Africa
    Home Page:
    http://www.javak.co.za
    Hi.

    Inheritance isn't a bad thing, and I don't believe it will complicate your code, in fact, it would make it a little bit simpler as you could call the parent methods and to lighten the amount of code in your child classes.

    Good design should save you time and effort, if it doesn't, you might need to revisit the design.

    Best regards
     
  4. abilonds

    abilonds New Member

    Joined:
    Sep 23, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for the answers. My application can be done with inheritance, and I'm thinking I'm going with it.

    Thanks.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice