nukleus said:
If variables are declared at the top of the methods,
then all the error conditions and variable values
could be seen if you set a breakpoint in correct place
cause they won't go out of scope.
Fair point.
I absolutly hate "code reviews".
It simply means that there is some smart ass,
sitting on the top of a bunch of dummies,
telling them how screwed up they are,
and all it produces at the end
is guilt, leading to fear
to lose onse skin.
I don't like them either, but some organizations like them, especially
when they have a high proportion of new grads to knock out the code.
My worst case: the project's Technical Manager defined the coding
standards - basically standard K&R layout and naming conventions (it was
an ANSI C project) - and then went on holiday. Meanwhile I'd finished
detailed design and three of us had written and tested the project's
specialized function library, which included an in-memory active data
dictionary. At this point the Tech Manager returned from holiday and
re-issued the coding standards. Somebody must have dropped him on his
head while he was away because he now mandated Hungarian Notation
(Microsoft's poison gift to the world). I hit the roof because we had no
time or resource to rewrite the library code. The Project Manager should
have canned the new standard, but instead said we were both right. The
end result was that everybody else wrote horrible hungarianised code
while I and the other technical designers wrote to K&R standards.
The moral of this is: NO radical changes to project standards once
they've been issued. EVER.
In fact we didn't use code reviews on that project despite having a
large grad coding population, but we did require them to write module
specs in pseudo code and we reviewed that to make sure they had
understood the tech spec. That worked well and the end result, a large,
scalable multi-process system had no gross functionality, control or
interfacing problems.
Then, after contructor code, i like to put the highest,
possibly thread level methods, such as start, stop, run,
Terminator (ever heard of such an animal), and things
like that.
I put main() (if there is one) first, but if there's a main() the
probably are no constructors. Then I put public methods followed by
protected and private methods. Within each group of methods they're
simply in alphabetic order for ease of reference within the source file.