Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not a matter of performance, as the two have completely different semantics.</p> <p>The first gives you a way to use one object to find another object.</p> <p>The second gives you a way to use one object to find another object, in which you can use yet another object to find a third object.</p> <p>There is slightly different functionality in terms of how these can be later extended.</p> <p>Most generally, I'd use <code>Dictionary&lt;Tuple&lt;string, string&gt;, string&gt;</code>. This would give me a composite key that is clearly a composite key.</p> <p>Actually, that's not true, I'd create a new class. How is that not an option? Still, if it was homework and "do not create a new class" was part of the question, I'd use <code>Dictionary&lt;Tuple&lt;string, string&gt;, string&gt;</code>.</p> <p>Edit:</p> <pre><code>class DialectQuery : IEquatable&lt;DialectQuery&gt; { public Dialect{get;private set} public Name{get;private set;} public DialectQuery(string dialect, string name) { Dialect = dialect; Name = name; } public bool Equals(DialectQuery other) { return other != null &amp;&amp; Name == other.Name &amp;&amp; Dialect == other.Dialect; } public override bool Equals(object other) { return Equals((object)other); } public override int GetHashCode() { int dHash = Dialect.GetHashCode(); return (dHash &lt;&lt; 16 | dHash &gt;&gt; 16) ^ Name.GetHashCode(); } } </code></pre> <p>So far it behaves exactly the same as Tuple. Now though if I get a change request that dialects must be case-insensitive but query names case-sensitive, or that dialects are codes and therefore require invariant comparison but names are human-input and therefore require culture-aware comparison, or anything else, I've got two simple changes to make.</p> <p>YAGNI doesn't apply, it's not coding a massive object "in case you need it", it's defining a good "okay, I probably don't need it, but if I do it'll go here" point.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload