4 ms·
Ask HN: Does code documentation increase contributions?
I'm trying to convince a team working on a complex open-source project that they need to document all the code they write.
They have documentation for some public APIs, but most of the code only has an occasional comment. Otherwise, there is no data structure, function, or module documentation. I.e. no explanations what they represent, or do, no member or argument descriptions, and no overall module introductions.
For now I'm trying to focus on a single argument: better code documentation will bring more outside contributors by making it easier for them to figure the code out. The project is corporate-funded, already has a lot of users, and is present in all major Linux distributions and FreeBSD, but sees little outside contributions.
To me the answer seems obvious, but I would like to hear your opinions, if possible see actual data, or at least anecdotal evidence of any effect.
General opinions on the need for most, if not all code being documented are also welcome.
Thank you!
- jjgreen 10y agoDocumentation has a cost, and a risk. It must be maintained when the code changes, if not one deceives future developers and increase the chance of bugs. Ideally the code itself should be documentation enough; keep code comments for complex parts of the code which are not obvious -- these comments then stand-out because they are rare. The only place where you should document the obvious is in the public API, so I'd say the existing team are probably on the right path. Sorry :-)
- spbnick 10y agoThanks! Yes, I hear the same from them and I try to consider this approach :) It is an additional effort, for sure. It is not without its benefits, though, and I'm trying to find out if it's worth it. Why I originally brought this up with them is because I started working on a feature and found the code barely comprehensible. I spent a lot of time to try to keep everything in my head and failing repeatedly and felt like documentation would have helped me a lot. I.e. I was exactly in the position of a new external contributor and found the experience lacking.
- brudgers 10y agoTo me, the composition of a community is probably not a technical issue and is more likely to be a social issue. In a way, this question sort of highlights the social versus technical gap. The identified problem is lack of new outside contributors. The proposed solution: 1. mandates more work by existing contributors. 2. does not directly recruit outside contributors. 3. is structured to require a cultural shift of the existing community. 4. is a hypothetical without support from reasonable evidence. To put it another way, what I see from across the internet is a community that makes changes by argument rather than consensus, and reaches out to the world of potential contributors for support to win the argument. It doesn't seem to be so much about writing good documentation or determining what documentation is actually necessary for the purpose. It's more rallying the troops. Curious about what the project is and why someone might want to contribute. Good luck.
- spbnick 10y agoThank you for a thoughtful response. I'm a bit confused by your answer, though, because my problem was the lack of documentation, and making it easier for external contributors was an argument I was using, not the other way around. However, I think I see your points, and I would agree with them otherwise. I experienced the problem first-hand, trying to add a feature to a complicated piece of code almost devoid of documentation, and spending a lot of time and energy on trying to hold everything in my head. Eventually I gave up and changed my approach, succeeding in the end, but documentation would have made it much easier, in my opinion. I approached the team suggesting a few measures we could implement, with increasing levels of effort, and argued that they will help us get more external contributions, since that was an already recognized problem and easier to argue for. It seemed logical to me, coming from my experience. I.e. making it easier to understand the code would make it easier to contribute. There are other arguments I could have used, but they are harder to defend, and some of them especially so, since the team already knows the code well. There were a variety of responses, but also one request for actual data on the effect of code documentation on number of contributors, which I came asking for here, after my Google searches failed. I.e. I'm asking for evidence, supporting or otherwise. I agree that community composition is mostly a social issue. I'm intrigued by your description: "a community that makes changes by argument rather than consensus". Could you elaborate? I feel I could learn something here. I would rather not specify the project to keep the discussion abstract and unbiased. Although for anyone really interested that information is a few Google searches away, I expect. People might want to contribute fixes or small features, because the project is already quite widely used and is essential for bigger companies using Linux.