|
From: Serge Lobko-L. a. a. <ser...@gm...> - 2006-08-24 07:51:01
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title></title>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
body {
margin: 5px 5px 5px 5px;
background-color: #ffffff;
}
/* ========== Text Styles ========== */
hr { color: #000000}
body, table /* Normal text */
{
font-size: 9pt;
font-family: 'Courier New';
font-style: normal;
font-weight: normal;
color: #000000;
text-decoration: none;
}
span.rvts1 /* Heading */
{
font-size: 10pt;
font-family: 'Arial';
font-weight: bold;
color: #0000ff;
}
span.rvts2 /* Subheading */
{
font-size: 10pt;
font-family: 'Arial';
font-weight: bold;
color: #000080;
}
span.rvts3 /* Keywords */
{
font-size: 10pt;
font-family: 'Arial';
font-style: italic;
color: #800000;
}
a.rvts4, span.rvts4 /* Jump 1 */
{
font-size: 10pt;
font-family: 'Arial';
color: #008000;
text-decoration: underline;
}
a.rvts5, span.rvts5 /* Jump 2 */
{
font-size: 10pt;
font-family: 'Arial';
color: #008000;
text-decoration: underline;
}
span.rvts6
{
font-size: 11pt;
font-family: 'tahoma';
font-weight: bold;
color: #ffffff;
}
span.rvts7
{
font-size: 11pt;
font-family: 'tahoma';
}
span.rvts8
{
font-size: 11pt;
font-family: 'tahoma';
font-weight: bold;
}
a.rvts9, span.rvts9
{
font-size: 11pt;
font-family: 'tahoma';
color: #0000ff;
text-decoration: underline;
}
span.rvts10
{
font-family: 'arial';
}
span.rvts11
{
}
span.rvts12
{
font-size: 8pt;
font-family: 'arial';
font-style: italic;
color: #c0c0c0;
}
a.rvts13, span.rvts13
{
font-size: 8pt;
font-family: 'arial';
color: #0000ff;
text-decoration: underline;
}
/* ========== Para Styles ========== */
p,ul,ol /* Paragraph Style */
{
text-align: left;
text-indent: 0px;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
.rvps1 /* Centered */
{
text-align: center;
}
--></style>
</head>
<body>
<p>Guys,</p>
<p><br></p>
<p>Why don't we use GUIDs?</p>
<p><br></p>
<p>Wednesday, August 23, 2006, 10:03:36 PM, you wrote:</p>
<p><br></p>
<div><table border=0 cellpadding=1 cellspacing=2 style="border-color: #000000; border-style: solid;">
<tr valign=top>
<td width=14 style="background-color: #0000ff;">
<p><span class=rvts6>></span></p>
</td>
<td width=681 style="background-color: #ffffff;">
<p><span class=rvts7>I guess my main issues at this point are:</span></p>
<p><br></p>
<p><span class=rvts7>1) Some one can inadvertantly use the same naming scheme as is proposed, in fact I can see many an exporter using this exact naming scheme.</span></p>
<p><span class=rvts7> How about we use a hash of the final key value and prepend that to the type name?</span></p>
<p><br></p>
<p><span class=rvts7>2) rename NextKey to GetNextKey, NextKey sounds like a property, GetNextKey is a definite action.</span></p>
<p><br></p>
<p><br></p>
<p><br></p>
<p><span class=rvts7>On 8/23/06, </span><span class=rvts8>Andreas Bednarek</span><span class=rvts7> <</span><a class=rvts9 href="mailto:an...@se...">an...@se...</a><span class=rvts7>> wrote:</span></p>
<p><span class=rvts7> </span></p>
<p><br></p>
<p><span class=rvts7>And where does this get called from? So far I don't see much difference from the current implementation.</span></p>
<p><span class=rvts7> </span></p>
<p><span class=rvts10>The GenerateKey() should have been called before Add(key, item) when there is no actual value for the key (simply outside AxiomCollection). Not very cool either so thought of a better idea, see below. </span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts10>Also the main difference is, that the Add(T item) is removed. I remember finding some bugs in SceneManager where CreateCamera, CreateSceneNode and maybe some more methods were using the simple Add(T item) thus not using the appropriate name the objects were created with. Just like the Foo example in Terry's post.</span></p>
<p><span class=rvts7> </span></p>
<p><span class=rvts10>(Another diff is that the key is now unique.)</span></p>
<p><span class=rvts7> </span></p>
<p><span class=rvts10>How about this?</span></p>
<p><span class=rvts7> </span></p>
<p><span class=rvts7> </span></p>
<p><span class=rvts10>- RENAME the Add(T item) method as maybe it is a bit confusing, name it AddAutoKey(T item) for example. It simply does more than just adding.</span></p>
<p><span class=rvts10>- Let it generate the autokey (fix current uniquity issue) and let it return the key to the caller if maybe needed</span></p>
<p><span class=rvts10>- (nextUniqueKeyCounter could be 'uint' not 'int' and checked for overflow - just little thing)</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts10>This might be a simple although indirect solution to the issues that initiated this thread. The 'bandaid' Terry mentioned does not go away unfortunately, but whether that hurts really... also by revisiting all the existing code that shall use the new method name, it can be easily checked whether the previous Add(item) was used correctly.</span></p>
<p><span class=rvts10>Just maybe.</span></p>
<p><span class=rvts10> </span></p>
<p><br></p>
<p><span class=rvts11> public class AxiomCollection<K, T> : SortedList<K, T> where K : IConvertible</span></p>
<p><span class=rvts11> {</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> ...</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> static protected uint nextUniqueKeyCounter;</span></p>
<p><span class=rvts11> </span></p>
<p><span class=rvts11> ...</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> /// <summary></span></p>
<p><span class=rvts11> /// Accepts an unnamed object and names it manually. </span></p>
<p><span class=rvts11> /// </summary></span></p>
<p><span class=rvts11> /// <param name="item">Item to be added to the collection.</param></span></p>
<p><span class=rvts11> /// <returns>The autogenerated key that was used when adding the item to the collection.</returns></span></p>
<p><span class=rvts11> public virtual K AddAutoKey( T item )</span></p>
<p><span class=rvts11> {</span></p>
<p><span class=rvts11> K key; // = default( K ); ??</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> while ( base. ContainsKey( key = NextKey( item ) ) )</span></p>
<p><span class=rvts11> ;</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> base. Add( key, item );</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> return key;</span></p>
<p><span class=rvts11> }</span></p>
<p><span class=rvts10> </span></p>
<p><br></p>
<p><span class=rvts11> private K NextKey( T item )</span></p>
<p><span class=rvts11> {</span></p>
<p><span class=rvts11> K key;</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> if ( typeof( K ) == typeof( string ) )</span></p>
<p><span class=rvts11> {</span></p>
<p><span class=rvts11> key = ( K ) Convert. ChangeType( typeof( T ). Name + nextUniqueKeyCounter, typeof( K ) );</span></p>
<p><span class=rvts11> }</span></p>
<p><span class=rvts11> else</span></p>
<p><span class=rvts11> {</span></p>
<p><span class=rvts11> key = ( K ) Convert. ChangeType( nextUniqueKeyCounter, typeof( K ) );</span></p>
<p><span class=rvts11> }</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> checked( nextUniqueKeyCounter++ );</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts11> return key;</span></p>
<p><span class=rvts11> }</span></p>
<p><span class=rvts11> }</span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts10> </span></p>
<p><span class=rvts7> </span></p>
<p><br></p>
<p><span class=rvts7>-------------------------------------------------------------------------</span></p>
<p><span class=rvts7>Using Tomcat but need to do more? Need to support web services, security?</span></p>
<p><span class=rvts7>Get stuff done quickly with pre-integrated technology to make your job easier </span></p>
<p><span class=rvts7>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo</span></p>
<p><a class=rvts9 href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642</a></p>
<p><br></p>
<p><span class=rvts7>_______________________________________________</span></p>
<p><span class=rvts7>axiomengine-developers mailing list</span></p>
<p><a class=rvts9 href="mailto:axi...@li...">axi...@li...</a></p>
<p><a class=rvts9 href="https://lists.sourceforge.net/lists/listinfo/axiomengine-developers">https://lists.sourceforge.net/lists/listinfo/axiomengine-developers </a></p>
<p><br></p>
<p><br></p>
</td>
</tr>
</table>
</div>
<p><br></p>
<p><br></p>
<p><br></p>
<p><br></p>
<p><span class=rvts12>-- </span></p>
<p><span class=rvts12>Best regards,</span></p>
<p><span class=rvts12> Serge </span><a class=rvts13 href="mailto:ser...@gm...">mailto:ser...@gm...</a></p>
</body></html>
|