Prev: Binary heap "tie breaking" question
Next: CFP: SAS'2010 - 17th International Static Analysis Symposium, Perpignan, France
From: cbcurl on 11 Feb 2010 10:30 On Feb 10, 7:19 pm, Moi <r...(a)invalid.address.org> wrote: > On Wed, 10 Feb 2010 15:01:32 -0800, Daniel wrote: > > It would be helpful for me to have an abbreviation of the word "array". > > Or an abbreviation for an alternate word that means the same thing. I > > use the word "array" as used in C, Java, or any standard language. > > > I am not afraid of long variable and function names. I generally follow > > the naming recommendations in "Code Complete". > > > But I also find special abbreviations often to be more memorable and > > useful, such as cnt for count, ndx for index, pck for pick, lo / hi for > > low / high, var for variable, rng for range, max / min, etc. And I have > > some variable names that are so long that it would help me to try > > abbreviating "array". > > > I was thinking "ara" or "ary", but am not that excited about them, maybe > > because they have two syllables or maybe because I (and others) am not > > used to them. > > > Any thoughts? Is there a standard or suggested way to abbreviate the > > s > > struct person { > int num; > char name[111]; > date birth; > } persons[] = > {{ 1, "moi", 123456789} > ,{ ... } > }; > This is what I have done for years, using the plural form of a noun for arrays or other container types. I loath type-encoding naming conventions like Hungarian because they force you to rename your variables every time you refactor their types. The compiler does a fine job of keeping track of static type declarations, so what is the point of forcing the poor developer to maintain a type-encoding naming convention? - Christopher
From: bartc on 11 Feb 2010 12:12 cbcurl wrote: > On Feb 10, 7:19 pm, Moi <r...(a)invalid.address.org> wrote: >> } persons[] = >> {{ 1, "moi", 123456789} >> ,{ ... } > This is what I have done for years, using the plural form of a noun > for arrays or other > container types. This is not too reliable. Would be npersons be a number, or an array? -- Bartc
From: Daniel on 11 Feb 2010 12:52 On Feb 11, 9:12 am, "bartc" <ba...(a)freeuk.com> wrote: > cbcurl wrote: > > On Feb 10, 7:19 pm, Moi <r...(a)invalid.address.org> wrote: > >> } persons[] = > >> {{ 1, "moi", 123456789} > >> ,{ ... } > > This is what I have done for years, using the plural form of a noun > > for arrays or other > > container types. > > This is not too reliable. Would be npersons be a number, or an array? > > -- > Bartc Thanks for additional suggestions. In response to last few posts: Yes, I confess _g indicates global variables. I use as few as possible, but it ends up being a lot. There is a lot of data that applies to the whole program. In practice, the global variables have not caused a problem for the program. Probably because I'm pretty careful about naming and using access routines. And externs are automatically generated. I also dislike Hungarian. I agree I am slipping and sliding in that direction. But I do want to know that it's an array, without having to guess or remember. There are cases where is helps make variable names partly "implementy", as someone said. I agree RWA_CAT_Set_HiPckNdx_Array_g is obscure. I know what it means, but it probably looks like garbage to others. On the other hand, it's trying to describe a complex concept, so it's going to take some effort to understand no matter what. I could make the name (and others like it) longer, but that might mean lines over 80 columns, which I still avoid, at least for ".c" files. The reason for the underscores it twofold. 1) Easier to read. 2) Parallel with other names. There is a series of such global names, like ROA_CAT_IMP_IntFmt_ColCnt__g ROA_RNG_RUN_Unique_ID______g etc. etc. Making the names parallel makes it much easier to keep track of everything and build common access functions. Yes, something like categorical_set_high_pick_index is MUCH easier to read and less jarring. But it would have to be twice as long to really describe the complex concept, and also the parallel concept would break down too, once I started just optimizing each name by itself. I appreciate the "s" suggestion. I take it that means change int *RWA_CAT_Set_HiPckNdx_Array_g [CAT_VAR_CNT]; to int *RWA_CAT_Set_HiPckNdxes_____g [CAT_VAR_CNT]; (or something similar) to indicate each RWA (read-write array) array slot contains (points to) series of "CAT_Set_HiPckNdxes". (Sorry I previously omitted declaration.). I think maybe I used to use "s" and for some reason changed to "Array" because it seemed clearer to me what was going on (array instead of count). One problem is the "s" might disrupt the way the parallel organization of names. For example, BOOL RWA_CAT_Pck_IsMarked_Array_g [CAT_VAR_CNT]; changes to RWA_CAT_Pcks_AreMarked_____g and now not parallel with RWA_CAT_Set_HiPckNdxes_____g. Maybe it's close enough and would work. Anyway, I appreciate the suggestion. Daniel
From: Ted DeLoggio on 12 Feb 2010 11:38 Daniel wrote: > It would be helpful for me to have an abbreviation of the word > "array". > Or an abbreviation for an alternate word that means the same thing. > I use the word "array" as used in C, Java, or any standard language. > > I am not afraid of long variable and function names. I generally > follow > the naming recommendations in "Code Complete". > > But I also find special abbreviations often to be more memorable and > useful, such as cnt for count, ndx for index, pck for pick, lo / hi > for > low / high, var for variable, rng for range, max / min, etc. And I > have > some variable names that are so long that it would help me to try > abbreviating "array". > > I was thinking "ara" or "ary", but am not that excited about them, > maybe because they have two syllables or maybe because I > (and others) am not used to them. > > Any thoughts? Is there a standard or suggested way to abbreviate > the word "array"? I looked in "Code Complete" and searched the > internet and found very little mention. > > Thanks, > Daniel p? -- Ted DeLoggio
From: BGB / cr88192 on 14 Feb 2010 11:57
"Daniel" <google-cal(a)ehdp.com> wrote in message news:1745db59-1138-4c53-a640-977ff62bdca8(a)t34g2000prm.googlegroups.com... snip all... <-- RWA_CAT_Set_HiPckNdx_Array_g - Original name. Need to trim by 2 RWA_CAT_Set_HiPckNdx_A_g - Too obscure? It's certainly short. RWA_CAT_Set_HiPckNdx_Ra_g - Not personally attracted to this one RWA_CAT_Set_HiPckNdx_Vec_g - Many people don't know what vector is. RWA_CAT_Set_HiPckNdx_Ray_g - Not bad, but I like arr better. RWA_CAT_Set_HiPckNdx_Arr_g - Kind of like it (ARR! ARR! ARR!) RWA_CAT_Set_HiPckNdx_Ptr_g - Avoid naming issue. Use different concept. RWA_CAT_Set_HiPckNdx_RWA_g - Extend existing internal convention --> IMO, this naming convention is horrid... it doesn't really look all that likely to address, well, any of the usual reasons for using naming conventions: clarification (what is code, what does it do, ...); improving modularity (by avoiding clashes and reducing "accidental" code/data sharing). one would actually just be almost better off using plain hungarian... there is also the variant where the type is added on as a suffix (rather than a prefix), usually so that the start of the name can be used for scope-related purposes (usually though, the main reason I would do this would be to facilitate overloading in C, where the same conceptual function may be used with different argument types, ...). I typically don't do as much with variables, as most variables are either locals or contained in a struct, and thus don't need as much (usually names for locals are kept short). in the cases I use globals, usually they are scope-named, but I don't do much more than this (although, often, globals are marked static, since as a general rule I don't share globals, and even then, it is usually only with other code in the same library/subsystem, and out of necessity). even then, globals typically hold "non-volatile" data (they are either constant data or semi-constrant / "stable"). storing volatile values in globals is something I try to avoid if possible. it can be very problematic, especially if multi-threaded code is involved and it is possible that threads may step on the variable (for constant data, threads don't matter, and for semi-constand data, it only requires that a mutex be used to syncronize access if multiple threads may be involved, such as to remove risk of threads seeing the data in an inconsistent state). most other data then goes into special structs which are used as contexts (usually these holding much of the shared state for a given subsystem, and may in turn hold pointers to other contexts, ...). or such... |