What To Do Right As a New Programmer?
globeadue writes "My company just tagged me for full time App Dev — I've essentially never coded for money, but the last 3 years of support desk gives me the business sense to know the environment I'll be coding for. Now my company will be training me, so I think the technical side of things will be covered, what I'm looking for is best practices, habits I should/shouldn't develop, etc as I take on my new craft."
Read The Risks Digest -- it ought to be required reading for all software developers because it is fundamentally about how systems fail and if you don't have a good grasp of how the system you are building might fail, then you will probably build it in such a way that it will fail like a house of cards the first time a stiff breeze blows.
It is low volume with pretty high signal-to-noise ratio so it is not a burden to stay current, and when you have some dead time the back issues - going back for more than two decades now - make for great reading too.
When information is power, privacy is freedom.
I'm far from a master programmer myself, but this much I know.
While it's a ridiculous example, someone could easily change
std::string mkdec(std::string x) // Converts x, a string representing a hexidecimal number, to a decimal string.
To
std::string mkdec(std::string x) // Do a little dance, make a little love, get down tonight
And everything would still compile just fine, but all of a sudden new devs on the project are left in the dark as to what mkdec() does without reading through its code. If someone named the function convert_hex_string_to_decimal_string something cryptic or incorrect it would appear in many places (everywhere the function was used) and be much more noticeable and likely get fixed sooner.
Another fun one I've seen in legacy codebases a lot is
//Only used in this place or that place, or for this or that purpose.
int some_func() { blah }
... and that comment was written 5 years ago and is completely wrong. People used doxygen or intellisense or whatever and saw that this function exists and takes the input/output they want but never saw that comment so they used it in 1000 other places.
Or another fun one.
/* function foo()
... big long description of inputs, outputs, constants that affect it, whatever ...
does this, that, and another thing.
*/
void foo() {blah }
... and the description is horribly out of date because it's been changed a million times.
I'll say it again: the compiler can't check your comments, and it's just too easy to change some code that will make a comment wrong and not realize it. So comments have their place but their use should be judicious.
"Self documenting code" (good variable and function names, etc) that the compiler can verify for you are preferable.