http://wiki.apidesign.org/index.php?title=Talk:FriendPackages&feed=atom&action=historyTalk:FriendPackages - Revision history2024-03-29T08:32:25ZRevision history for this page on the wikiMediaWiki 1.12.0rc1http://wiki.apidesign.org/index.php?title=Talk:FriendPackages&diff=1675&oldid=prevJaroslavTulach: Talk:APIDesignPatterns:FriendPackages moved to Talk:FriendPackages2008-11-15T12:38:46Z<p><a href="/wiki/Talk:APIDesignPatterns:FriendPackages" title="Talk:APIDesignPatterns:FriendPackages">Talk:APIDesignPatterns:FriendPackages</a> moved to <a href="/wiki/Talk:FriendPackages" title="Talk:FriendPackages">Talk:FriendPackages</a></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 12:38, 15 November 2008</td>
</tr>
</table>JaroslavTulachhttp://wiki.apidesign.org/index.php?title=Talk:FriendPackages&diff=1541&oldid=prevJaroslavTulach at 09:29, 25 October 20082008-10-25T09:29:23Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 09:29, 25 October 2008</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 2:</td>
<td colspan="2" class="diff-lineno">Line 2:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': Accessor could perhaps be called ItemAccessor (living in ItemAccessor.java)? This makes it more obvious that you have to write this boilerplate for each class needing the back door. TBa</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': Accessor could perhaps be called ItemAccessor (living in ItemAccessor.java)? This makes it more obvious that you have to write this boilerplate for each class needing the back door. TBa</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* ''JST'': Actually once per package is enough.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">[[User:JaroslavTulach|</ins>''JST''<ins style="color: red; font-weight: bold; text-decoration: none;">]]</ins>: Actually once per package is enough.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? </div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* ''JST'': This is [[wikipedia::mediawiki]] and it has a lot of extensions. More than I know about.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">[[User:JaroslavTulach|</ins>''JST''<ins style="color: red; font-weight: bold; text-decoration: none;">]]</ins>: This is [[wikipedia::mediawiki]] and it has a lot of extensions. More than I know about.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': The particular point is the line l = listener in Item.java. This is presumably so that in the presence of multiple threads, an "obsolete" listener may be called, but you will never get a null pointer exception. That's too much to clutter the code with, but it spent quite a bit of my effort working it out.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': The particular point is the line l = listener in Item.java. This is presumably so that in the presence of multiple threads, an "obsolete" listener may be called, but you will never get a null pointer exception. That's too much to clutter the code with, but it spent quite a bit of my effort working it out.</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* ''JST'': The current code is not really multithreaded.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">[[User:JaroslavTulach|</ins>''JST''<ins style="color: red; font-weight: bold; text-decoration: none;">]]</ins>: The current code is not really multithreaded<ins style="color: red; font-weight: bold; text-decoration: none;">. As far as the initialization goes, it shall not matter, as it is expected that the ''setDefault'' method is part of implementation not API and as such it will be called just once</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': Should all the "default"s really be called "default"? aren't we really talking about TheAccessor or something? </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': Should all the "default"s really be called "default"? aren't we really talking about TheAccessor or something? </div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* ''JST'': I am not sure I get the comment, but [[NetBeans]] usually call singleton returning methods getDefault(). Having symmetrical setDefault(...) is appropriate, I guess.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">[[User:JaroslavTulach|</ins>''JST''<ins style="color: red; font-weight: bold; text-decoration: none;">]]</ins>: I am not sure I get the comment, but [[NetBeans]] usually call singleton returning methods getDefault(). Having symmetrical setDefault(...) is appropriate, I guess.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': It is much clearer setting the DEFAULT directly than the book's indirect classloader method, but now shouldn't setDefault be synchronized?</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* ''TBa'': It is much clearer setting the DEFAULT directly than the book's indirect classloader method, but now shouldn't setDefault be synchronized?</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* ''JST'': The classloading trick is still there, I just moved it outside of the code snippets. It is only necessary if someone uses Accessor first without Item being loaded (e.g. which is only possible while calling constructor, I guess):</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">[[User:JaroslavTulach|</ins>''JST''<ins style="color: red; font-weight: bold; text-decoration: none;">]]</ins>: The classloading trick is still there, I just moved it outside of the code snippets. It is only necessary if someone uses Accessor first without Item being loaded (e.g. which is only possible while calling constructor, I guess):</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><source lang="java" snippet="design.less.friend.InitAPI"/></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><source lang="java" snippet="design.less.friend.InitAPI"/></div></td></tr>
</table>JaroslavTulachhttp://wiki.apidesign.org/index.php?title=Talk:FriendPackages&diff=1540&oldid=prevJaroslavTulach at 19:30, 24 October 20082008-10-24T19:30:20Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 19:30, 24 October 2008</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Accessor could perhaps be called ItemAccessor </del>(<del style="color: red; font-weight: bold; text-decoration: none;">living in ItemAccessor.java</del>)<del style="color: red; font-weight: bold; text-decoration: none;">? This makes it more obvious that you have to write this boilerplate for each class needing the back door</del>. <del style="color: red; font-weight: bold; text-decoration: none;">TBa</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">Comments by Tim Band </ins>(<ins style="color: red; font-weight: bold; text-decoration: none;">''TBa''</ins>).</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* JST: Actually once per package is enough.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">''TBa'': Accessor could perhaps be called ItemAccessor (living in ItemAccessor.java)? This makes it more obvious that you have to write this boilerplate for each class needing the back door. TBa</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* ''</ins>JST<ins style="color: red; font-weight: bold; text-decoration: none;">''</ins>: Actually once per package is enough.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? <del style="color: red; font-weight: bold; text-decoration: none;">The particular point is the line l = listener in Item.java. </del>This is <del style="color: red; font-weight: bold; text-decoration: none;">presumably so that in the presence of multiple threads, an "obslete" listener may be called, but you will never get a null pointer exception. That's too much to clutter the code with, but </del>it <del style="color: red; font-weight: bold; text-decoration: none;">spent quite </del>a <del style="color: red; font-weight: bold; text-decoration: none;">bit </del>of <del style="color: red; font-weight: bold; text-decoration: none;">my effort working it out</del>. <del style="color: red; font-weight: bold; text-decoration: none;">TBa</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* ''TBa'': </ins>It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* ''JST'': </ins>This is <ins style="color: red; font-weight: bold; text-decoration: none;">[[wikipedia::mediawiki]] and </ins>it <ins style="color: red; font-weight: bold; text-decoration: none;">has </ins>a <ins style="color: red; font-weight: bold; text-decoration: none;">lot </ins>of <ins style="color: red; font-weight: bold; text-decoration: none;">extensions. More than I know about</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Should all the "default"s really be called "default"? aren't we really talking about TheAccessor or something? TBa</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* <del style="color: red; font-weight: bold; text-decoration: none;">JST</del>: <del style="color: red; font-weight: bold; text-decoration: none;">[[NetBeans]] usually call singleton returning methods getDefault()</del>. <del style="color: red; font-weight: bold; text-decoration: none;">Having symetric setDefault(</del>...<del style="color: red; font-weight: bold; text-decoration: none;">) </del>is <del style="color: red; font-weight: bold; text-decoration: none;">appropriate, I guess</del>.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">''TBa''</ins>: <ins style="color: red; font-weight: bold; text-decoration: none;">The particular point is the line l = listener in Item</ins>.<ins style="color: red; font-weight: bold; text-decoration: none;">java</ins>. <ins style="color: red; font-weight: bold; text-decoration: none;">This is presumably so that in the presence of multiple threads, an "obsolete" listener may be called, but you will never get a null pointer exception</ins>. <ins style="color: red; font-weight: bold; text-decoration: none;">That's too much to clutter the code with, but it spent quite a bit of my effort working it out</ins>.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* ''JST'': The current code </ins>is <ins style="color: red; font-weight: bold; text-decoration: none;">not really multithreaded</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">It is much clearer setting the DEFAULT directly than the book</del>'s <del style="color: red; font-weight: bold; text-decoration: none;">indirect classloader method, but now shouldn</del>'t <del style="color: red; font-weight: bold; text-decoration: none;">setDefault be synchronized</del>? <del style="color: red; font-weight: bold; text-decoration: none;">TBa</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* </ins>'<ins style="color: red; font-weight: bold; text-decoration: none;">'TBa'': Should all the "default"</ins>s <ins style="color: red; font-weight: bold; text-decoration: none;">really be called "default"? aren</ins>'t <ins style="color: red; font-weight: bold; text-decoration: none;">we really talking about TheAccessor or something</ins>? </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* ''JST'': I am not sure I get the comment, but [[NetBeans]] usually call singleton returning methods getDefault(). Having symmetrical setDefault(...) is appropriate, I guess.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* JST: The classloading trick is still there, I just moved it outside of the code snippets. <del style="color: red; font-weight: bold; text-decoration: none;">Just click on the name of the source file above each code snippet.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">''TBa'': It is much clearer setting the DEFAULT directly than the book's indirect classloader method, but now shouldn't setDefault be synchronized?</ins></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">** </del>It is only necessary if someone uses Accessor first without Item being loaded (e.g. which is only possible while calling constructor, I guess)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* ''</ins>JST<ins style="color: red; font-weight: bold; text-decoration: none;">''</ins>: The classloading trick is still there, I just moved it outside of the code snippets. It is only necessary if someone uses Accessor first without Item being loaded (e.g. which is only possible while calling constructor, I guess)<ins style="color: red; font-weight: bold; text-decoration: none;">:</ins></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">** Otherwise the setDefault is still being called from static { </del>... <del style="color: red; font-weight: bold; text-decoration: none;">} initializer and as such it is synchronized on the Item class.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>*<del style="color: red; font-weight: bold; text-decoration: none;">* I </del>might <del style="color: red; font-weight: bold; text-decoration: none;">try </del>to put a guard in constructor of Accessor:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"><source lang="java" snippet="design</ins>.<ins style="color: red; font-weight: bold; text-decoration: none;">less</ins>.<ins style="color: red; font-weight: bold; text-decoration: none;">friend</ins>.<ins style="color: red; font-weight: bold; text-decoration: none;">InitAPI"/></ins></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><source lang="java"<del style="color: red; font-weight: bold; text-decoration: none;">></del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">protected Accessor() {</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins style="color: red; font-weight: bold; text-decoration: none;">'JST': It </ins>might <ins style="color: red; font-weight: bold; text-decoration: none;">be possible to </ins>to put a guard in constructor of Accessor <ins style="color: red; font-weight: bold; text-decoration: none;">just like in this example</ins>:</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"> if (!getClass().getName().equals(</del>"<del style="color: red; font-weight: bold; text-decoration: none;">api</del>.<del style="color: red; font-weight: bold; text-decoration: none;">AccessorImpl</del>"<del style="color: red; font-weight: bold; text-decoration: none;">)) {</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><source lang="java" <ins style="color: red; font-weight: bold; text-decoration: none;">snippet=</ins>"<ins style="color: red; font-weight: bold; text-decoration: none;">forjoe</ins>.<ins style="color: red; font-weight: bold; text-decoration: none;">InterfaceThatJustJoeCanImplement</ins>"/></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"> throw new IllegalStateException();</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"> }</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">}</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"><</del>/<del style="color: red; font-weight: bold; text-decoration: none;">source</del>></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">and then the need for synchronization would be completely gone.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
</table>JaroslavTulachhttp://wiki.apidesign.org/index.php?title=Talk:FriendPackages&diff=1539&oldid=prevJaroslavTulach at 16:47, 24 October 20082008-10-24T16:47:59Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 16:47, 24 October 2008</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Accessor could perhaps be called ItemAccessor (living in ItemAccessor.java)? This makes it more obvious that you have to write this boilerplate for each class needing the back door. TBa</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Accessor could perhaps be called ItemAccessor (living in ItemAccessor.java)? This makes it more obvious that you have to write this boilerplate for each class needing the back door. TBa</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* JST: Actually once per package is enough.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? The particular point is the line l = listener in Item.java. This is presumably so that in the presence of multiple threads, an "obslete" listener may be called, but you will never get a null pointer exception. That's too much to clutter the code with, but it spent quite a bit of my effort working it out. TBa</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? The particular point is the line l = listener in Item.java. This is presumably so that in the presence of multiple threads, an "obslete" listener may be called, but you will never get a null pointer exception. That's too much to clutter the code with, but it spent quite a bit of my effort working it out. TBa</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Should all the "default"s really be called "default"? aren't we really talking about TheAccessor or something? TBa</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Should all the "default"s really be called "default"? aren't we really talking about TheAccessor or something? TBa</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* JST: [[NetBeans]] usually call singleton returning methods getDefault(). Having symetric setDefault(...) is appropriate, I guess.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>It is much clearer setting the DEFAULT directly than the book's indirect classloader method, but now shouldn't setDefault be synchronized? TBa</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>It is much clearer setting the DEFAULT directly than the book's indirect classloader method, but now shouldn't setDefault be synchronized? TBa</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* JST: The classloading trick is still there, I just moved it outside of the code snippets. Just click on the name of the source file above each code snippet.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">** It is only necessary if someone uses Accessor first without Item being loaded (e.g. which is only possible while calling constructor, I guess)</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">** Otherwise the setDefault is still being called from static { ... } initializer and as such it is synchronized on the Item class.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">** I might try to put a guard in constructor of Accessor:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"><source lang="java"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">protected Accessor() {</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> if (!getClass().getName().equals("api.AccessorImpl")) {</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> throw new IllegalStateException();</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> }</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">}</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></source></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">and then the need for synchronization would be completely gone.</ins></div></td></tr>
</table>JaroslavTulachhttp://wiki.apidesign.org/index.php?title=Talk:FriendPackages&diff=1538&oldid=prevTimBand: Improvement suggestions2008-10-24T13:21:00Z<p>Improvement suggestions</p>
<p><b>New page</b></p><div>Accessor could perhaps be called ItemAccessor (living in ItemAccessor.java)? This makes it more obvious that you have to write this boilerplate for each class needing the back door. TBa<br />
<br />
It would be nice to be able to put in extra comments without cluttering up the text. Hovers would be ideal, but I guess not supported by this Wiki (and not in the code section anyway). Is there any way of doing footnotes? The particular point is the line l = listener in Item.java. This is presumably so that in the presence of multiple threads, an "obslete" listener may be called, but you will never get a null pointer exception. That's too much to clutter the code with, but it spent quite a bit of my effort working it out. TBa<br />
<br />
Should all the "default"s really be called "default"? aren't we really talking about TheAccessor or something? TBa<br />
<br />
It is much clearer setting the DEFAULT directly than the book's indirect classloader method, but now shouldn't setDefault be synchronized? TBa</div>TimBand