Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958563

Pages: 1
CJHam
Unregistered




Mistake in Figure 7 on isLeaf() Post It Note
      #5894 - 04/01/04 06:54 PM

Small mistake in "Figure 7. A component node adapter.".

Mistake is in the far right side Post It Note, where it says:
"
public boolean isLeaf() {
return component.getComponentCount() > 0;
}
"

This is wrong. You can see that isLeaf() wouldn't return true when it really was a leaf.

Checking the article confirms this: the author's Java code is correct, but his UML class model is an accidental fudge of these two methods from the Java code:

public boolean isLeaf() {
return !isContainer();
}

public boolean isContainer() {
return getComponent().getComponentCount() > 0;
}

Great article though. Nice practical example of Adapter. In general, excellent UML use.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 5499

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5