Jesus, I hate to get into what's going to turn into a flame war...
but here goes anyway...
The "majority consensus" you refer to is no more a consensus than the
opinion of any other group of programmers, a large proportion of whom are
notoriously difficult to convince of anything they don't already believe.
Ask ten people on this newsgroup where the curly braces should be, and
you'll get ten different opinions, and each one of them will insist at the
top of his lungs that his is the ONLY RIGHT WAY to do it.
Nonsense. There's no such thing as an only right way to do anything. At a
minimum, for anything you can name, there are probably at least three only
right ways to do it.
But it happens that a lot of opinion leaders in this industry do believe
that it's better to be using some kind of guidelines than none, and that
there's no single right way to do anything. They also believe that Microsoft
is not the last word - the tablets come down from the mountain in the arms
of Moses - on the issue of coding guidelines.
Look at the mess that Microsoft made of Hungarian notation, prior to .Net.
The originator's original intent for Hungarian notation was to tag variables
NOT with their data types, but with a simple encoding of semantics that
relate to the application domain that you're developing in (you can look it
up). The Microsoft C++ team and the Windows OS team changed that excellent
idea and turned it into a horribly torturous encoding of primitive data
types, and practically forced it on us with all the code they gave us in,
for instance, the ghastly MFC. Thank God they finally came to their senses
and threw Hungarian overboard.
"Do what you prefer but do it consistently?" Sure. Look at other people's
code, look at the Microsoft samples, talk to other programmers whose
opinions you respect, and ask them WHY they choose to do particular things.
Then think about whether it makes sense to you, and try it out. If it works
for you, add it to your own evolving sense of programming style. If you a
very junior programmer, with no style that you've already developed, start
with Microsoft's and see how well it works.
If you're working at a company that has a large body of existing code that
uses a particular style of coding, use that style while you're programming
for them. If you don't like it much, talk to the senior programmers there -
particularly the ones who have been there a long time - and ask them why
they do it that way. Maybe they don't like it either, and maybe with them
you can move things in a better direction. If you code in a radically
different style, you'll later on be forcing other programmers who take over
your code to learn your style just to be able to read the code YOU wrote,
when all the rest of the code at the company reads a different way. They
won't appreciate that.
Not all programming styles are good. There are some very bad things you can
do, that improve your chances of making errors in your coding. Those you
need to weed out of your own style (if you have one). Where do you find out
what's generally considered badness in coding style? The earliest source
books on guidelines in the C programming family (C, C++, C#, Java) are, for
example, "C Programming Guidelines" by Tom Plum, and "C++ Programming
Guidelines" by Plum and Dan Saks. They're dated in many respects, but one
thing they do well is identify the basic bad techniques, such as having
variables that differ from each other only in the case of one letter and so
on.
For more modern guidelines, I like the Microsoft .Net guidelines, but I
don't swallow them whole either. I've largely adopted them when I program in
the .Net languages, but my own style still contains some techniques that
differ from Microsoft's. These are things that work well for me and that I
see no need to change. At the company where I presently work, I largely use
the style of the existing code, just so that when someone else at the
company looks at it, or when I leave the code behind for someone else, it
will look familiar and easy to read for whoever takes it over.
Regards,
Tom Dacon
Dacon Software Consulting
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in message
news:up**************@TK2MSFTNGP06.phx.gbl...
Every single time neophytes or converts ask about naming and style
conventions what are they told by the majority consensus? The answer is
"do what you prefer but do so consistently" right? Yes, that's right,
that's exactly what is said. People joining a team of developers are also
encouraged to cooperate with their peers and adopt what has already been
established right? Yes, that's exactly what is encouraged.
Teamwork and cooperation is a good thing. The guys on the blue team wear
blue jerseys and the guys on the red team wear red jerseys. Neophytes and
converts alike look to their team for guidance and leadership; Microsoft
and accomplished peers/colleagues.
JavaScript and C# are exactly the same syntactically and if syntax and
style are best used CONSISTENTLY and in COOPERATION with what has been
established as the CONVENTION we have to consider the following
hyopcritical contradiction in terms....
By convention, Microsoft has established the syntax for C#, C++, J# and
JScript... to be written using symmetrical code blocks which I think it
correct to conclude most developers agree to be the most readable, usable,
most reusable, most efficient etc...
// Microsoft's C#, C++, J# and JScript...
symmetrical code block
{
...
}
Just like untrained puppies, leave them alone for a minute and Microsoft's
hypocrital developers will sh!t on your new carpet...
// Microsoft's Atlas...
asymmetrical code block{
...
}
"A double minded man is unstable in all his ways."
-- James 1:8
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/