Are there any research papers about effects of writing documentation and commenting code on software quality, maintainability, and team productivity?
-
I am an advocate of commenting on source code and documenting software products. It is my personal experience and observation that working on source code that is rigorously commented has helped me in different ways when I have had to grow software or maintain it. However there's another camp that says commenting is ultimately worthless and its value is questionable. Numerous proponents of coding without commenting argue that: If a piece of code is well-written, it is self explanatory and hence does not need commenting If a piece of code is not self-explanatory, then refactor it and make it self-explanatory so that it does not need any comments Your test suite is your live documentation Over time code and comments get out of sync and it becomes another source of headaches Agile says working code is more important than piles of documentation, so we can safely ignore writing comments To me this is just dogma. My personal observation has been that software written by teams of smart and experienced developers ultimately end up with a considerable amount of code that is not self-explanatory, looks ugly, and needs courage to touch. The Java API, Cocoa API, Android API, etc. show that if you want to write and maintain quality documentation, it is possible. Another argument here is that these are APIs for libraries and frameworks, not for end-products and That end-products (software that rely on these libraries and APIs) do not need documentation and commenting. Having said all these, conversations about pros and cons of documentation and commenting on source code that are based on personal beliefs usually do not end well and lead to no satisfying conclusions. As such I am looking for academic papers and empirical studies about the effects of software documentation, especially commenting source code, on its quality and maintainability as well as its effects on team productivity. Have you stumbled upon such articles and what's been the outcome of them, if any? EDIT: I am adding links to related articles that I find here. Some are just opinions and editorials though. http://queue.acm.org/detail.cfm?searchterm=source+code+comment&id=957782 (ACM)
-
Answer:
I have always found writing documentation results in cleaner, better-constructed code because you have to think about what you're doing. In a large development environment, with multiple development branches between developers, poor documentation is an absolute guarantee for incompatible code and patch conflicts. In code bases that are highly stable over long periods of time (10-15 years in some of the cases I've seen) and where this means no subject matter expertise exists, refactoring code without side-effects (Heisenbugs, usually, but also entirely valid but undocumented external references) is dangerous and requires extreme care. You don't just go in there and do it, even perfectly good, perfectly compliant code can affect things out of scope. Such situations often cascade. Fix one supposed flaw, create two or more new ones. It's not the code that's wrong, it's the understanding. Code with extremely high levels of correctness use code verifiers that compare what you say you think you've written with what you've actually written. In other words, they work because the code has been commented. Take a look at Spark 2012, or the SEL4 microkernel for how to use contract-based programming of this sort. Agile is not necessarily a good way to produce clean code or robust code. Although certainly not representative, when I've been brought in to fix a company's software, every case has been a case of code produced by Agile. Please note, this is not a defect in Agile, it is a defect in the use of Agile. The method, if misapplied, produces terrible results. Even correctly applied, I'd not use it in anything Mission Critical. It's a convergent method, it's great when you don't have true specifications and must evolve rather than engineer. But there's a price to be paid, which is that it IS evolutionary and convergent, you're never "there" and you're never quite sure what "there" is anyway. Do coders like documenting? Usually no, but if you took away the documentation they relied on (there'll be bookshelves and half a desk surface of the stuff), the air would turn blue and it's quite possible you will witness spontaneous human combustion. No coder likes to write it, but no coder can survive without it. One thing you've got to understand is that most of us get absorbed, hyper-focussed, on the tasks. We forget that the manuals on which we utterly depend we're written by people just as absorbed and just as loathing of writing. We forget development isn't iterative but recursive, that someone depends utterly on the manual we're damned and determined not to write. There is no such thing as self-documenting code, coders are no better at writing test harnesses than they are at writing manuals, and if I'd a penny for every broken patch merge I had to manually fix, I'd have $143 and 19 cents.
Jonathan Day at Quora Visit the source
Other answers
Well, there is this one great study, but it hasn't been documented yet, so ... I'm with you on commenting code that isn't painfully obvious, but not on X number of comments per Y lines of code. Some code is about as self-explanatory as the comment itself, so the comment is redundant. Some is about as self-evident as the thinking of a tree, so you'd better comment it if you want to work on it tomorrow. "If a piece of code is well-written, it is self explanatory and hence does not need commenting" Show me a bit-banger port with NOPs thrown around that's "self-explanatory" to someone who doesn't know what a T-State is. (And COBOL is as self-documenting as snow is flaming hot.) "Your test suite is your live documentation" Maybe to a good programmer, but not to the end-user. And not to the person who writes the manual for the end-user. (Not that well-thought-out programming should need much explanation for the end-user.) "Over time code and comments get out of sync" And that time is shorter the worse the programmer is. It takes a few seconds to modify the comment. Keep modifying the code and putting off modifying the comment, and pretty soon the comment won't have anything to do with the code. "Agile says working code is more important than piles of documentation" Piles? Yes. Any? That's why I don't like techniques like Agile. They look as if they were designed by efficiency experts, not computer engineers (IOW, people talking out of places they should be sitting on). Write a piece of code a few thousand lines long, with no commenting or documentation. Go back 6 months later, after not having thought about it all that time, and explain what it does. (I can still explain the 8080 bit-banger I wrote in 1973, because it was commented - including the differences in timing in the branches - so it could easily be modified as CPU speeds went up.)
Al Klein
I was blessed with a lousy memory so I wrote however many comments in my code that I thought were needed so I would be able to figure out what the heck I had done in six months when I was back in the code again. Why wouldn't you add code comments? It only takes a few seconds and can save one's successor, or in my case oneself, from screwing things up on the next pass. If nothing else, comments show what one's intent was, if the code does something else the comment lets you know it was a mistake. It always seemed to me that one needed to at least define the input and output variables to a process. How could this not be worth the little time that it takes?
Frank Popa
Related Q & A:
- I need help with writing up the Java Code.Best solution by Yahoo! Answers
- How to improve my code to make the video quality better?Best solution by Stack Overflow
- What are the differences between people who have dyslexia, and people who have a hard time writing papers?Best solution by Yahoo! Answers
- Can you have a degree in just Legal Research and Writing?Best solution by wikihow.com
- Is there any best software available to enhance the video quality?Best solution by movavi.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.