• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaBeans method name prefixes

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are standard JavaBeans name prefixes for methods?

My source of confusion is K&B book. Page# 68 of this book says:

JavaBeans methods must be named using camelCase and depending on the method's purpose, must start with set, get, is, add or remove.

Whereas, Answer 1 to Chapter# 1's SelfTest Question# 5 says:

'add', 'delete', & 'put' are not standard JavaBeans name prefixes

Now why is 'add' mentioned at both places?
 
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question comes up frequently; search the forum for the words 'add' and 'bean' and you'll get several topics.

The best to look at is this one which includes a reply from Bert explaining where to look in the book for fuller answers.

The summary is that "addXxxListener" is a valid JavaBean method name. In the context of the review question, "addSize" is not. Read the link for more exhaustive detail.
 
jaspreet atwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stevi Deter:

The summary is that "addXxxListener" is a valid JavaBean method name. In the context of the review question, "addSize" is not. Read the link for more exhaustive detail.



aah! Thanks Stevi, my wrong...
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This also will help you:
https://coderanch.com/t/262282/java-programmer-SCJP/certification/JavaBeans-naming-standard
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic