writing professional code

I would like to know how the professionals among you write proffessional code.

I downloaded an example that Adrianxw wrote (that button thing). And noticed some interesting things, like he declares every variable on a new line, puts every argument on a new line. Why, was this just for a easy readable example or will this truly benefit when you write large programs?

Also how do you handle realy large WndProc (WindowFunc in the example) Because, If you have a large menu, big WM_PAINT, Scrollbar and all that stuff in it, it can be very big. And it would be hard to read or find anything in it.

And how about global variables. Do you say they are the devil?
Is it better to make a function pass 10 variables then make a few global?

How many line of code do you usually put in one file?

Let's hear it proffies. Give the amateur some pointers

Also, maybe attach some programs you made, they don't have to be complete or working.
It is just to learn the style

Not that I'm what you would call a "professional", but I do write software for my company which is in use on a daily basis, so I guess I shall comment on this topic.

Basically, the only difference between my personal coding and the coding I do for my company is that I comment a lot more, making sure that everything is explained, because I know that I will not be here forever, much less much longer.

As far as coding practices in general, I tend to put several global variables in modules/classes that I can turn on/off depending on the various situations. Some people feel that global varialbes are dangerous, and yes, they are at times, but as long as you're careful, there's no need to worry too much.

Anyways... I guess that's about it... I code, I comment, I produce. That's it.

Every professional team of programmers has a set of rules called a "coding standard". Look for some public ones on the web. They define how a team member has to write code, so each member can easily understand and modify it later. In a team, most of the time there aren't 100% C gurus. Some are fluent in Java, C#, Scripting or even ASM. But all have enough experience to have a look into other fields, if all of them are organized cleanly.

Example:

char* a,b;

For a normal non-C programmer, this clearly reads: two char*'s, one named a, one named b. First line of code, first silly misunderstanding.

char* a;
char b;

Much better.

char* a = NULL;
char b = 0;

Even better yet. Always initialize variables.

Then there are naming standards. Our company will always prefix class names with "CSAZ" as this clearly shows it's a class ("C") and if something fails we ( "saz" ) can grab the guy who wrote it and make him change it. Just one example. Look up hungarian notation for more naming standards.

hth
-nv

She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."