Should object be created with minimal scope?
<p>This one may seem trivial to some, but I'm trying to adopt good habits right from the start... </p>

<p>Should objects always be created with minimal scope?</p>

<p>In the example below, <code>corner1</code> only gets used inside the loop. Is it best practice to then create (declare) it inside the loop? </p>

<p>i.e. do this </p>

<pre><code>    for(int i = 0; i &lt; 1; i++){
        DoubleVector corner1 = new DoubleVector();

        // code where corner1 gets used
    }
</code></pre>

<p>and not</p>

<pre><code>    DoubleVector corner1;

    for(int i = 0; i &lt; 1; i++){
        corner1 = new DoubleVector();

        // code where corner1 gets used
    }
</code></pre>

<p>Of course, if I need <code>corner1</code> later on, then I guess I have to go with the second option. </p>
