• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Kathy Sierra book - doubt - javaBeans name convention

 
Marcelo Ribeiro
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Kathy's book page 68 says:


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


and on the self test it says:


A, C, and E are incorrect because 'add', 'delete' and 'put' are not standard JavaBeans
name prefixes. (Objective 1.4)


could anyone please explain what I lost because, first it says that "add" should be used then says it should not.

Thanks in advance!
 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read again properly. It says 'add' can be used with Listener methods. And in example it uses 'add' with no Listener method.

I think I make you clear.
 
Marcelo Ribeiro
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the explanation, but it is not so clear yet, at these examples:

public void removeMyListener(MyListener m) //correct

public void addXListener(MyListener m) // listener type mismatch


at books's question the option where we have add is:

addSize


if it was
addListenerSize


would it be correctly?

Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic