So where do you place your local method variables?
A question of style, as I'm currently lacking in this department.
(One of the many bonuses coming from being mostly self-taught).
At the moment I seem to just place the definition of local method-variables anywhere in the vicinity of where I'll first use them. The idea of course being that the declaration and use of said variables should be as close to each other as possible. Often this leads to the code being easier to decipher, but the code isn't nearly as neat/clean looking as I would like. I am therefore starting to reconsider this approach.
I am considering placing the definitions as early as possible in the method which should give a nice and quick overview of any local variables that are going to be used. This should tidy the code up as well.
Any comments/alternatives/thoughts?
A question of style, as I'm currently lacking in this department.
At the moment I seem to just place the definition of local method-variables anywhere in the vicinity of where I'll first use them. The idea of course being that the declaration and use of said variables should be as close to each other as possible. Often this leads to the code being easier to decipher, but the code isn't nearly as neat/clean looking as I would like. I am therefore starting to reconsider this approach.
I am considering placing the definitions as early as possible in the method which should give a nice and quick overview of any local variables that are going to be used. This should tidy the code up as well.
Any comments/alternatives/thoughts?