Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Bean

 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what way is a Java Bean advantageous. Apart from the demarcation that it is a component, does it have any other special features.
I wish to know one more thing. A java Bean is a typical class. Won't it have the same too many object instatiation as a typical class. What are its major advantages as far as the threading issues are concerned.
Regds
Shiva
 
Murilo Beriam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A java bean is a simple data structure which is responsible for carring data and not complex logic. You should determine the rules for getting and setting attibutes but nothing beyond this. Coding this way, the final result will show lots of classes with the responsibility well distributed. Each class has its own role in the system and data structure is the java bean responsibility. It's like a style of coding.
There are some advantages using these beans, like the built-in facilities in the servlet engine.
Think of the use of the tag jsp:useBean, for instance. It is really useful.
 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about the object creation issues. Aren't they created as a simple java class does. That could be heavy if the hits are more compared to a servlet.
shiva
 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes, there can be serious bottlenecks if javabean is not coded correctly and scope is not setup appropriatly. You can store ton of info in the instance variables and instantiate for every request. It can even bring the server down.
Ideally Java bean should not be more than a value object with getters/setters with all business logic delegated to a helper class/ejb.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic