How Experienced And Novice Programmers See Code 238
Esther Schindler writes "We always talk about how programmers improve their skill by reading others' code. But the newbies aren't going to be as good at even doing that, when they start. There's some cool research underway, using eye tracking to compare how an experienced programmer looks at code compared to a novice. Seems to be early days, but worth a nod and a smile."
Reader Necroman points out that if the above link is unreachable, try this one. The videos are also available on YouTube: Expert, Novice.
Re:Code? (Score:5, Insightful)
Novice programmers overwhelmed (Score:4, Insightful)
Novice programmers are simply overwhelmed by vast amounts of code, and have no idea how to do large-scale software development.
When you teach them about tools that allow you to find your way through the code, they're all impressed.
Universities simply aren't teaching these boys right.
Re:Comments (Score:5, Insightful)
Comments that describe what the code is doing are useless. Comments that describe why the code does what it does are invaluable.
Re:Comments (Score:5, Insightful)
If I'm reviewing untrusted third-party code, or code which is suspected to be buggy, I agree, but it really slows things down, even at an expert level, to completely ignore comments, if it's a setting where I'm working with people I know to be good engineers, and am not actively debugging/auditing their code. There has to be some amount of trust to make large projects work, and trusting that my colleagues are writing sane and reasonably accurate comments is one form of it. If it turns out to be wrong in a certain case, well, that's what tests are there to discover.
Re:Comments (Score:5, Insightful)
Those inline comments are good (when done properly) when trying to quickly grok through a large codebase. That "done properly" bit is important. Obviously a comment that just states what the following line does is pointless.. but a one liner generalizing a 9 or 10 line block of code means 9 or 10 lines of code you can skim over.
Obviously if troubleshooting code or auditing you want to focus on the code, but then the comments still serve as a good tool to indicate potential problems by as you said, showing what the authors intention was. If the code doesn't match the comment.. the code might very wlel be wrong.
Re:Code? (Score:5, Insightful)
An experienced coder just sees everything as unintelligible crap that only a moron would write.
Re:Comments (Score:5, Insightful)
Depends on the level of granularity. Comments that describe what a single line of code does (or even a small number of lines of code in many cases) are useless.
Comments that describe the behavior of a suitably large block of code (e.g. a function or a block within a particularly complicated function) can help you quickly understand the structure of a program as a whole. This is critical when working with sufficiently large bodies of code, because you're unlikely to have time to read every line of code before you start hacking away at it. For sufficiently complex projects, they can also be pulled out by tools such as HeaderDoc or Doxygen and converted into documentation.
At a semi-coarse granularity, comments that tell you what a block of code within a function does can make it much easier to find the code you need to change when something doesn't work. Thus, even those comments can be useful, so long as each comment covers at least a handful of lines of code and so long as the "what" isn't instantly obvious at a glance.
I'll hazard a guess: (Score:4, Insightful)
Young programmers see code as a way to show how good they are
Old programmers see code as something that puts money in the bank.
What off topic ?
Re:Novice programmers overwhelmed (Score:5, Insightful)
Unfortunately if you give them the most advanced tools possible then they never actually *leave* the novice state since they're too used to their tools doing all the work for them.
Re:Code? (Score:4, Insightful)
Polish: Making wood shine at the beginning of a sentence.
Re:Skipping (Score:3, Insightful)
This is one of the things that makes teaching so difficult. If it were just a matter of explaining what you do, it would be simple, but for many tasks you don't actually know. You have to learn all over again when it comes time to teach it.
Re:Code? (Score:3, Insightful)
I feel immense shame, horror and bewilderment when I look at my old code. Did I really write this rubbish?