dcsimg
Question on JavaBean specs to return something other that <code>void</code>
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Thomas_SMETS
Posted On:   Wednesday, October 10, 2001 08:28 AM

I'm currently working on a project where the core development is a set of JavaBeans implementing Neural Network data analysis. I propose to implement the JU nit tests but the setXXX() should return the value set to simplify the testing. This technique allows to avoid the problem of having a setter & a getter being biaised in a way that we don't detect the biais. Does the JavaBean Specs accept the setMethods() to return something else than " void " ? As a matter of fact, the fact that a call returns something, or not, should not matter. Also, and unless the caller check the fact the setters    More>>

I'm currently working on a project where the core development is a set of JavaBeans implementing Neural Network data analysis.



I propose to implement the JU nit tests but the setXXX()
should return the value set to simplify the testing. This technique allows to avoid the problem of having a
setter
& a
getter being biaised in a way that we don't detect the biais.



Does the JavaBean Specs accept the
setMethods()
to return something else than "
void " ?



As a matter of fact, the fact that a call returns something, or not, should not matter. Also, and unless the caller check the fact the
setters returns something doesn't compromise the introspection attempt.


The question is therefore two fold :



  1. Is it accepted in the JavaBean specs to return something ?

  2. Does someone know cases where a tool using JavaBeans is having problem because of that ?



Tx for comments & remarks,



Thomas,

   <<Less

Re: Question on JavaBean specs to return something other that <code>void</code>

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, November 16, 2001 05:44 AM

1. it is not accepted.

2. if you specify something other than void in the setXXX(), you no longer have a JavaBean. period. it is now just a plain ol' java class since it is not in the JavaBeans specification. there are many components and tools that operate on JavaBeans. your class could not be used with them because it ceases to be JavaBean by returning a value from a setSomeProperty() call. keep in mind that most of these tools are using reflection. they look for setXXX methods that return void and if this is not the case for your class, it is not the JavaBean and cannot be utilized.
About | Sitemap | Contact