Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Observing the examples that you have provided -- The following:</p> <p><strong><code>operator++</code> (postfix/prefix)</strong></p> <p><strong><code>string.empty()</code> vs. <code>string == ""</code></strong></p> <p>Don't seem to be good examples, as they compare operations that are different in <code>functionality</code>. Hence, one better <strong>not</strong> disregard their semantic distinctions.</p> <p>In contrast, the following examples: </p> <p><strong><code>vector.empty()</code> vs. <code>vector.size() == 0</code></strong></p> <p><strong><code>enum</code>erate { <code>on</code>, <code>off</code>} vs. <code>boolean</code> <code>on=true</code>; <code>off=false</code></strong></p> <p>Are perfectly reasonable.</p> <p><code>vector.empty()</code> is preferable if the context of its use is only to determine if the vector is empty. At the risk sounding condescending (which I do <strong>not</strong> intend to be): this boils down to common sense. Why ask for the vector's size if you only want to know if it's empty? That's like asking someone how much money they have in their wallet when you simply wish to know if they have enough cash to by a Coke.</p> <p>As for <code>enum</code>erate { <code>on</code>, <code>off</code>} vs. <code>boolean</code> <code>on=true</code>; <code>off=false</code>, ask yourself this: how likely is it that you may add another value to the enumeration, in the future? It seems reasonable that one might want <code>enum</code>erate{<code>on</code>, <code>off</code>, <code>indeterminate</code>}` (or some variation), so the answer may be yes. Otherwise, a simple boolean would suffice.</p> <p>This leads me to the crux of your question: which seems to be if there is some deterministic/algorithmic approach to deciding one way or another on questions such as these, or their relevance? My answer is that until the day that <a href="http://en.wikipedia.org/wiki/Turing_machine" rel="nofollow noreferrer">Turing Machines</a> are able to pass the <a href="http://en.wikipedia.org/wiki/Turing_test" rel="nofollow noreferrer">Turing Test</a>, I would say No. This is the reason why humans are required to engineer software.</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. VO
      singulars
      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