java web applications and jar files

Discussion in 'Java' started by bahamuto@yahoo.com, Jan 18, 2005.

  1. Guest

    I have a question when it comes to java web applications and the use
    of jar files. If I have several web applications that will be using
    either the same or similar javabeans or just regular java classes in
    the application, should I put these java classes in a jar file so that
    they both get the class definition from that? The only other
    alternative I can see is to create a copy of the class files for each
    web application that needs that class, and that doesn't seem like good
    OO to me.

    Assuming that the best way to go on would be to put them in the jar
    files, should I make the class object in the jar file javabeans, or
    should I make them regular classes and make the javabeans more specific
    to the application that they are needed for?

    For instance lets say I have an object person who has the attributes:

    name
    ssn
    eyecolor

    If one application only needs name and eyecolor, and the other needs
    name and ssn should I make this whole object a javabean, or should I
    make two seperate javabeans in the the individual applications that
    would only use the attributes it would use.
    Thanks for any help in advance.

    - Nathan
     
    , Jan 18, 2005
    #1
    1. Advertising

  2. Tom Dyess Guest

    <> wrote in message
    news:...

    > For instance lets say I have an object person who has the attributes:
    >
    > name
    > ssn
    > eyecolor
    >
    > If one application only needs name and eyecolor, and the other needs
    > name and ssn should I make this whole object a javabean, or should I
    > make two seperate javabeans in the the individual applications that
    > would only use the attributes it would use.
    > Thanks for any help in advance.
    >
    > - Nathan
    >


    Given this example, I would create a Person object with name and ssn, then
    create a subclass AstheticPerson that inherits from Person and adds
    eyeColor. Since I prefer jar files, I would put them both in a single jar
    file and use Person for one application and AestheticPerson in another. If
    you don't think you will ever use AestheticPerson in any other application,
    I would just put Person in a jar file and inherit from it in the only
    application that uses it. Of course, there are "100 ways to skin a cat," so
    someone else would do something completely different. I would definitely
    superclass the common parameters though, that's proper OOD.
    --
    Tom Dyess
    OraclePower.com
     
    Tom Dyess, Jan 20, 2005
    #2
    1. Advertising

  3. Guest

    I don't know if subclassing is "proper OOD" - I think by now its widely
    accepted to prefer encapsulation to inheritance.

    My suggestion is to keep it simple - I don't see any need for keeping
    name, ssn, and eyecolor separately. I would create one bean type with
    both fields and share them between the two apps. Inheritance is
    overkill for this situation!
     
    , Jan 20, 2005
    #3
  4. Tom Dyess Guest

    <> wrote in message
    news:...
    >I don't know if subclassing is "proper OOD" - I think by now its widely
    > accepted to prefer encapsulation to inheritance.
    >
    > My suggestion is to keep it simple - I don't see any need for keeping
    > name, ssn, and eyecolor separately. I would create one bean type with
    > both fields and share them between the two apps. Inheritance is
    > overkill for this situation!
    >


    Yes, I agree, but I thought it was a hypothetical simplistic example and not
    what he was really doing. If that is all you are doing with the object,
    inheritance is overkill.
    ---
    Tom Dyess
    OraclePower.com
     
    Tom Dyess, Jan 20, 2005
    #4
  5. bahamuto Guest

    Yeah it was a simplistic overkill example. The classes themselves
    are not going to change, but I was just wondering if I should create
    bean classes in the specific applications to only use the fields
    specific to that web app.

    - Nathan
     
    bahamuto, Jan 21, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric McIntyre

    Jar files in Jar files

    Eric McIntyre, May 24, 2004, in forum: Java
    Replies:
    1
    Views:
    487
    Roedy Green
    May 24, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    599
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,755
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,811
    Roedy Green
    Feb 14, 2006
  5. Arnold Peters
    Replies:
    0
    Views:
    685
    Arnold Peters
    Jan 5, 2005
Loading...

Share This Page