On 31/10/2006, at 7:18 AM, Dave Camp wrote: On Oct 30, 2006, at 7:23 AM, Scott Ribe wrote:
I agree. It is a recent thing.
Even after years, I remain *shocked* at how hard many Windows IDEs make it to see your header and implementation next to each other. It is sheer UI *stupidity* to not make this easy.
And of course, V$ and Anjuta make it easy, by giving you control-tab, even if you have code windows appearing in a MDI way (no tabs) - and V$ has a feature that any young IDE should revere and meditate on - the BACK BUTTON, which works within a single file - this is an incredibly useful thing. I bet Xcode does have it, and someone will tell me how to work it. (or it will appear in 3.01_) And, of course, many of the IDEs out there are now oriented toward Java, where this is not an issue.
Maybe this explains Windows engineers tendency to put all their C++ code in the .h files? Almost every Windows port job I work on has 50-75% of the C++ source inlined in the .h files. I've never been able to get an explanation as to why I see this so often... that's got to put a lot of pressure on the linker to strip out all the duplicate code generated in each object file.
It's a messy business, programming. A lot of my "first-pass" prototype code is heavy on the headers, because I have a habit of just writing out my definition because I can. Of course, you start using a few #includes in that .h file and it soon becomes apparent that you need to put your definitions in a separate file so this file can be included by something else that doesn't need all the other stuff you #included for the definitions in this class. Header heirarchies can be a headache, can't they? Hmmm.
Having said that, when I first started in c++ i wrote bunches of stuff in header files, which experience taught me was much better off in definition files, that declaration files were for declaring things. That's why there's a semicolon after a class (struct / enum) declaration - only definition blocks need no trailing semi-colon. Declaratives (because they are statements) need a semi-colon. It made much more sense to start thinking of .cpp files as definition files and .h files as declaration files. I don't think everybody thinks of them that way.
That's my theory anyway.
OR ... I'd wager the code you're talking about was written for a client, on a deadline. That code tends to be less drafted than say, the next version of some production app where the client is six or seven figures and the code-audit is truly agonizing - for those projects we drafted, redrafted, circulated coding guidelines, had friday afternoon best-practice discussions, etc. If it was just some quick and dirty thing that was going to solve problems that day, for a few weeks or months, barring the company policies dictating the bare minimum "layout" or "design" we had to do, the less we "over-engineered" those apps the better, it meant we could get back to the big projects. That doesn't mean we completely ignored them, they got testing and QA, just not a whole bunch of formatting / optimising.
Where did you see your header-heavy files?
_david
|