Re: How to name variables in a program?



SerGioGio wrote:
> Hello,
>
> Having a strong convention for naming your variables in your program is an
> important issue often overlooked.
> Can anyone point me to a good source on the web dealing with this issue?
>
> SerGioGioGio
>
>

1. Use short labels on locals, long labels on globals. Reason: locals
are used for only a short length of code, have their declarations right at the
top (and presumably a good comment). Globals should have bigger, better labels.
Of course, even better is to reduce or eliminate global variables.

2. Don't use so called "hungarian" notation, courtesy of Microsoft, where types
are placed into the label name. Think of two people conversing:

"hi Dave (Person, Male, lives in California), I placed your desk (Large, computer,
contains keyboard drawer) chair (Red, padded, adjustable) back in your office
(manager level, closing door, has windows)."

Variables are shorthand for the task at hand. What matters to people is having
context, that is, being able to work in a small area (like a function) without
having to explain everything that is going on every time you do anything.

.



Relevant Pages

  • Re: User defined field labels
    ... What if you'd make those cboxes globals even in the param table? ... editing problem is solved but when entering find mode all the labels ... Since the labels are fields, entering find mode leaves the CBox label ... labels and have their change affect the host. ...
    (comp.databases.filemaker)
  • Re: swsusp.S: meaningfull assembly labels
    ... You just made those labels public! ... The LOCAL symbols need to ... no. They'll show up in the object file. ... while not 'globals' in the sense that 'C' ...
    (Linux-Kernel)