Re: How to name variables in a program?
- From: "Phlip" <phlip_cpp@xxxxxxxxx>
- Date: Sat, 28 May 2005 05:49:03 GMT
SerGioGio wrote:
> Having a strong convention for naming your variables in your program is an
> important issue often overlooked.
Many shops take that ideal reasonably seriously. They often couch it in a
larger ideal: The code should appear as if written by only one, very
intelligent individual. Put another way, you should not be able to tell who
wrote what by looking at its structure, style, format, or naming
conventions.
Get that by collaborating closely on each other's code.
> Can anyone point me to a good source on the web dealing with this issue?
Google for "intention revealing selector" for one topic. And here's a
summary of the rest:
- pronounce identifiers and statements out loud, to ensure they make sense
- methods are verb phrases
- classes are generic nouns
- objects are specific nouns
- use the same name for the same thing, spelled the same
- don't use l, i, O, etc. for local variables.
- Use spikey things like x, k, j, q, etc.
- don't use long names for local variables
- don't use short names for global things
- prefix strings with s or str
- prefix objects or references with a
- prefix pointers with p
- don't prefix anything else - rely on clarity
- use CapitalizedNames for important things
- use camelCase for methods
--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
.
- Follow-Ups:
- Re: How to name variables in a program?
- From: August Karlstrom
- Re: How to name variables in a program?
- References:
- How to name variables in a program?
- From: SerGioGio
- How to name variables in a program?
- Prev by Date: Re: How to name variables in a program?
- Next by Date: Re: groups.google.co.uk is gone
- Previous by thread: Re: How to name variables in a program?
- Next by thread: Re: How to name variables in a program?
- Index(es):
Relevant Pages
|