What is your preferred order of elements in the body of program code? Why?
<p>Of course at the top of a .java or .cs file are the package/namespace declaration followed by import/using statement.</p>

<p>But what riles me is where should I put the variable declaration? At the top or at the bottom?</p>

<p>This is how I prefer;</p>

<pre><code>package/namespace declaration
import/using declaration of microsoft's/java namespaces
import/using declaration of standard 3rd party namespaces
import/using declaration of my personal namespaces

constructors
private methods, each preceded by any private variable that was first used.
protected methods, each preceded by any private variable that was first used.
public methods, each preceded by any private variable that was first used.

inner/nested classes and enums

private anon classes assignment
protected variables/anon classes assignment
public variables/assigned anon classes assignment
</code></pre>

<p>But I realise many people like to put all the variables right at the top after the     package/namespace and import/using declarations. That is troublesome because sometimes the number of variables and assigned anon classed gets too many, and that obscures the visibility of the constructors - the first lines I need to be visible are the constructors because they tell me the signature of instantiation.</p>

<p>And then for anon classes that are immediately assigned to a variable - I consider them part of the "structure of variables", so I group them variables.</p>

<p>I systematize the placement of my code elements to enable me to easily locate them.</p>
