[Please do not mail me a copy of your followup]
Jorgen Grahn <
grahn...@snipabacken.se> spake the secret code
<slrnn41qni.5...@frailea.sa.invalid> thusly:
>On Mon, 2015-11-09, Gareth Owen wrote:
>> Juha Nieminen <nos...@thanks.invalid> writes:
>>
>>> Alf P. Steinbach <
alf.p.stein...@gmail.com> wrote:
>>>> I prefer "a" and "b" for such naming.
>>>>
>>>> But I can understand "sI" and "sII".
>>>>
>>>> And in the case of a source and a destination, the old 1970's C
>>>> convention is "s" and "d".
>>>
>>> Why the love for brevity? Why must everything use as few characters as
>>> possible?
>
>Sometimes there's just not anything more to say.
In 1978, my team went insane with "coding style" guidelines. One
programmer started writing (in C++ identifier form)
the_loop_variable
instead of
i
to get code like:
for (int the_loop_variable = 0; the_loop_variable < 10; ++the_loop_variable)
{
cout << the_loop_variable << '\n';
}
It uniformly made his code harder to read.
This is the difference between guidelines and rules. When there is a
rule that says "single letter variable names aren't allowed", then you
get the above nonsense. When there is a guideline that says "avoid
unnecessarily abbreviated variable names" or "use variable names to
reveal your intent", then loop variables like i or source/destination
variables for copying like s and d are just fine. They are idiomatic
and common enough that people aren't confused in reading the code.
Of course, idiomatic programming is something that you pick up from
reading other people's code and having a discussion about it. Anyone
can learn the syntax from a book describing the grammar, but they are
unlikely to pick up the idioms without reading realistic code. K&R
did a good job of explaining both syntax and idioms in "The C
Programming Language". Bjarne Stroustrup does a similarly good job in
"The C++ Programming Language". What a pity it is that so many people
refuse to listen to the creators of either language.
--
"The Direct3D Graphics Pipeline" free book <
http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <
http://computergraphicsmuseum.org>
The Terminals Wiki <
http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <
http://legalizeadulthood.wordpress.com>