java web applications and jar files

B

bahamuto

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
 
T

Tom Dyess

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.
 
V

vkvask

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!
 
T

Tom Dyess

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.
 
B

bahamuto

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top