• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

general programming structure question.. order of declared variables

I've taken the habit of declaring variables in the order in which they appear in the document during processing.

When declaring variables or processing a large set of variables in which order is not important, how do you choose to order them? As they appear? Or alphabetically?
 
Usually as they appear and as close to the use as possible.

If the variables are all at the same place/scope, then I try to group related variables together and use and empty line to signify a group.

If I really have a large group of variables that are not related in any way, I generally start to question whether I have a good structure. A mass bulk of variables USUALLY (but not always) signifies that you need to think about you design some more.
 
Usually as they appear and as close to the use as possible.

If the variables are all at the same place/scope, then I try to group related variables together and use and empty line to signify a group.

I try and adhere to something like this too. I usually declare constants first as well.
 
I work with a globally dispersed team of people, so no matter what convention I choose, it won't be adhered to.

I work in C# 90% of the time, and in C# most of what's interesting is at class scope. I try to order my definitions like this...

public constants
public properties
public constructors
public methods
protected properties
protected methods
private properties
private methods
fields
 
Back
Top