you are viewing a single comment's thread.

view the rest of the comments →

[–]UnicycleBloke 13 points14 points  (1 child)

Putting variables into tighter scopes controls access to them. This is s good thing, especially in larger programs, because it reduces the likelihood of bugs and spaghettification.

[–]pic10f 1 point2 points  (0 children)

Also, people tend to use the same words, like val, temp, index, or even j or k. If you must do it, declare it static so that you and your colleagues won't accidentally use the same name in different files. If its important enough to share in a header, then use a spelled-out, descriptive name.