This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You've found a big honking, gravel-hauling errata...yikes! I'm really sorry, I don't know what happened there but something got WAY out of whack with that question!
Well we posting an errata list very soon, and when we do we'll post the link in this forum.
Thanks for your help,
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Saskia de Jong
Joined: Jan 24, 2006
Originally posted by Bert Bates:
Thanks for your help, Bert
You're welcome. At least thanks for the quick reply and for clearing this up
Btw, another question that I have doubts about is 1.5. It asks for valid method names according to the Javabeans standard. The answer is that 'addSize' is not correct, since 'add' is not a standard name prefix. However, 'add' certainly is a standard prefix for event listener registration.
Both the Javabean spec (section 6.5 page 29) and your book (page 9) says "add" + eventlistener type:
Now I'll agree that Size would be a strange name for an eventlistener, but I haven't seen it written anywhere that there's also a naming rule for the listener type itself. Specifically, your book makes no mention of the fact that the type names MUST end with "Listener". Therefore, when taking the self test one must assume "addSize" is a valid name.
Could you also clearify this issue?
Joined: Oct 14, 2002
I think this one isn't an errata, although I might add a sentence in the book to be a little more explicit. In section 8.4 of the JavaBean spec it states that Listener methods have to end with the literal "Listener".
Saskia de Jong
Joined: Jan 24, 2006
I see. Thanks a lot Bert!
For other people who are interested in this matter, this is what the spec exactly says in 8.4:
where both methods take the same �<EventListenerType>� type argument, where the �<EventListenerType>� type extends the �java.util.EventListener� interface, where the first method starts with �add�, the second method starts with �remove�, and where the �<EventListenerType>� type name ends with �Listener�.
(emphasis added by me) [ February 11, 2006: Message edited by: Saskia de Jong ]
Thanks Saskia and Bert. Good information. I think there's another thread around here somewhere where they were asking pretty much the same question.
I struggled when I saw that question too, but not because of the Listener bit. I just know how common it is to have addBlah and removeBlah in the real world when you have collections of Blahs as an instance variable for a class. I just assumed that was because it was part of the Java Beans spec. After missing the question I went and read it and found the stuff that you're referring to. It's funny the things you pick up as "standards" just because you see them so often. This is making me look closer at some of these things because Java Beans standards mean a lot in the real world since a lot of tools and infrastructures are using them with reflection for working with things. Good stuff to know.
Again, thanks, Josh [ February 11, 2006: Message edited by: Joshua Smith ]
regarding the other thread discussing Listener naming conventions, that was one of mine titled, imaginatively: "JavaBeans Listener naming conventions?" on Jan 31st, 2006. But what Bert and Saskia have said above reiterates those comments - ie: by quoting from Section 8 in the JavaBeans API spec.
Tim [ February 11, 2006: Message edited by: Timothy E. Hay ]
It's just what I reckon... ...but it's what I reckon.