Should these basic facts be known by all C++ developers? |
Probably not.
Let's go through them:
always initialise variables |
I've had professors not do this. I'm of the mindset that you should initialize variables in a class rather than waiting for a constructor to set them for you. I've been burned more than once by some dumb code where, for one reason or another, the constructor is not called. It blows my mind that one would REWRITE the variable name just to set it to nullptr in the constructor when they could have done so when creating the variable, less code, faster, and safer!
pass non-built-in types by const reference when in-parameters |
Don't even remember const references being taught, but it's possible they slid it in there somewhere.. I don't think the majority of students I was with in university would ever use a const reference.
know how short-circuit evaluation works and use it to prevent unnecessary execution of code |
I didn't know the terminology, but I knew the concept. I don't remember where I learned it, but I don't think it was from any professor..
avoid the use of using namespace std |
Consistently used and shoved down our throats as students, I doubt many of them even know what it really does besides let them type less code. I've tutored students in higher than beginner level coding classes who used it and didn't understand why it was a problem (a problem that has bitten me many times).
I don't know if it was taught as being particularly important.. And I know I'm very guilty of not doing so myself....
format code neatly and consistently |
Programming environments basically do half the job for us these days, yet I still see people creating horrid looking code - but not often.
I think the take away is.. assume they know nothing until proven otherwise.