Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When and how to use a javabean

 
Simon Harvey
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I was wondering if someone could help me figure out when to use javabeans.
In my application, I've made a bean that lets you connect to a database. I'm going to make another one that handles connection pooling. Does that sound ok?
OK, the other thin is that i want to make an object that will store details of an order (for example). Would this be a good bean? Would I then put it in the session or is there a better strategy
Basically, the thing I dont get is what the difference between a plain java bean and a plain class is? They both look roughly the same. So other thant the get/set conventions and the fact that beans can be placed in a visual builder, whats the big deal?
Kindest thanks
Simon
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, the thing I dont get is what the difference between a plain java bean and a plain class is? They both look roughly the same. So other thant the get/set conventions and the fact that beans can be placed in a visual builder, whats the big deal?
The main purpose of beans is to build reusable components and to have a standardized way for containers to interact with them thru introspection. Beans can interact with one another by firing property changes, thus providing a means of mediating state among several different beans. The idea is to be able to take some existing beans, put them together in various ways and produce a type of modular software.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course what Michael pointed is correct but according to me,
until u stop fight w/ uself about distinguishing b/w a bean and a simple class expecting miraculous differences then u will find urself in "unsatisfying" state as me.
bean is just a convention ppl follow which makes the simple class more useful because if we say something is a bean the third party can assume certain things about the class (even the JVM) and those components becomes easy to fit in different places still being very customizable.
well, just my 2 cents.
regards
maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic