Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Valid JavaBean name  RSS feed

 
Mansi Agarwal
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which java bean names are valid?

addListener
addMouseListener
removeListener
deleteMouseListener
registerMouseListener

Please reply..
 
Paul Clapham
Sheriff
Posts: 22491
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of them look like suitable names for a Java Bean to me. For one thing a Java Bean's name should follow the original Sun guidelines and start with an uppercase character.
 
ayush raj
Ranch Hand
Posts: 60
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham
" For one thing a Java Bean's name should follow the original Sun guidelines and start with an uppercase character. "


I think not every name is a valid Java Bean method name as long as the parameters of the methods matches with the method's names.

Eg :- If addMouseListener() will take a parameter , it can only be a MouseListener reference i.e addMouseListener(MouseListener m){ }

However , to delete a Listener , "remove" and to register a Listener ,"add" must be preceded with the function name.

So i think deleteMouseListener and registerMouseListener are not valid .
 
Mansi Agarwal
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about " addListener" is it valid?

Acc. to me it is not.
 
Anirudh Srivastav
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansi,

Are you asking us the naming convention for the methods which registers or removes the listener OR the valid names for the Javabean. The examples you have cited here sound like the ones which are suppose to register or remove the listeners

In case, your query has some thing to do with K&B book, the Javabean standard section @page 9 discuss ONLY the naming convention for the methods that are used to add or remove listeners from an event and not the valid name for the JavaBean.

Like Paul has said, none of the names you had listed are valid Javabean names. Javabean naming standard is similar to the way you name a class.


Refer 11.4 section of Javabean spec for more info.

Hope this helps!

 
ayush raj
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansi Agarwal:
"what about " addListener" is it valid? "


Even I am of the opinion that addListener as well as removeListener should not be a valid JavaBean name . So , addMouseListener is the only valid name according to me in the entire list of names as provided
by you. But still , if anybody is sure about it , please do reply and let us know the accurate answer .


 
Mansi Agarwal
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for clearing my doubt..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!