From: bartc on
cbcurl wrote:
> On Feb 11, 12:12 pm, "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?
>
> Use your head. What do you think it would mean?
>
> If you take the prefix 'n' to mean "number of", which is a common
> enough convention, then this would obviously be a number.

What if you had an array of those?

--
bartc


From: BGB / cr88192 on

"Daniel" <google-cal(a)ehdp.com> wrote in message
news:c33aa26f-6db2-4310-ab7c-693f9ce69fed(a)e19g2000prn.googlegroups.com...
On Feb 14, 8:57 am, "BGB / cr88192" <cr88...(a)hotmail.com> wrote:
> "Daniel" <google-...(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...

<--
I agree RWA_CAT_Set_HiPckNdx_Array_g looks horrid, but I don't see
much of an
alternative. It means an array ("RWA"), each element of which is an
array (actually
a pointer). Each element of the second array holds the "HiPckNdx" for
a "categorical
set". I won't try to explain what "HiPckNdx" or "categorical set" are.
It's domain-specific
to analyzing data. But they're certainly not Hungarian, although they
might look so to
someone not familiar with the domain. I think any program may look
horrid if you are
not familiar with the domain. The only parts that are Hungarian-like
are "RWA" and
"Array". I find them helpful to explain what the variable holds. As I
mentioned in
previous posting, there are many other symmetrically named variables
in a coding
convention. Anyway, I grant it's an imperfect system, but it works
well in practice.
I was just looking for a memorable 3-character name for "array".
-->

hungarian would actually look nicer...

anyways, usually stuff like this is much more a matter of style than of
domain.
usually, a similar style may be used regardless of the particular domain.

<--
Besides a lot of constant data, I do store a lot of volatile values in
globals that mostly
retain program settings the user has selected. I agree fewer globals
is better. But I
don't see any alternative. Luckily (I guess) the program is not multi-
threaded.
-->

bleh...


<--
Could you explain a little (or give a link or book reference) about
"special structs which
are used as contexts" as an alternative to globals? I'm not sure on a
practical level what
you're referring to. Do you save state to disk? I used to do that in
some cases, back
when memory was more of a concern, but moved away from it a while
back.
-->

no, no state goes to disk.


the simple desccription is that one has nearly all of their state stored in
a struct, and they pass a pointer to this struct around to all the places
they have code which may need any of this state.

anyways, this struct typically serves a similar role to a common use of
objects in OO languages, where nearly all of the functions which accept a
given context could be regarded as methods of the context/object.

so, usually, there will be a function to create/initialize the context (IOW:
a constructor), and often another to destroy it. for everything else, it is
passed around, and generally held by the creator (although, it is often
treated opaque outside of the code responsible for working on it).

I typically disallow direct access to struct fields, essentially demanding
that access be done via special functions designated as getters/setters...

similarly, different regions of code often use different contexts (or, IOW,
they are in different "objects").


or such...


From: cbcurl on
On Feb 16, 2:33 pm, "bartc" <ba...(a)freeuk.com> wrote:
> cbcurl wrote:
> > On Feb 11, 12:12 pm, "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?
>
> > Use your head. What do you think it would mean?
>
> > If you take the prefix 'n' to mean "number of", which is a common
> > enough convention, then this would obviously be a number.
>
> What if you had an array of those?

I can't imagine why one would have such a thing, but the plural would
be numbers-of-persons,
which I suppose one could abbreviate to ns-persons, although I
wouldn't. I would probably just
call it n-persons-array. See there is no hard and fast rule other than
to make the code readable
by humans.

From: mike on
In article <5225f641-a135-4c5f-a091-11eeb2731264
@z11g2000yqz.googlegroups.com>, cbcurl(a)gmail.com says...
> On Feb 16, 2:33 pm, "bartc" <ba...(a)freeuk.com> wrote:
> >
> > What if you had an array of those?
>
> I can't imagine why one would have such a thing, but the plural would
> be numbers-of-persons,
> which I suppose one could abbreviate to ns-persons, although I
> wouldn't. I would probably just
> call it n-persons-array. See there is no hard and fast rule other than
> to make the code readable
> by humans.
>
And then the number of entries in _that_ array would be n-n-persons-
array or n-ns-persons or ...
From: Willem on
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.

I always use 'arr' for arrays. Seems intuitive to me.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT