Ask HN: Separate code and comments?

2 points by trippplezz ↗ HN
I have a really weird problem at work. The project that I workon was developed mainly by a single person, and for some strange reason he doesn't want any comments in the code, quite literally.

Since I want to add comments in the code while I browse through the code making small modifications, basically getting accustommed to it, I was thinking about the possible solutions to this case:

* add the comments in my local working copy, then preprocess somehow the source files to strip the comments just before commit. I'm not sure how this will work when pulling/updating from the repo.

* An editor/IDE that have the ability to keep the comments separately as metadata and show them nicely for view/edit in its editor windows. Havent't found any still...

A similar question: http://stackoverflow.com/questions/1856133/separate-code-and-comments

4 comments

[ 0.21 ms ] story [ 18.5 ms ] thread
This sounds like "A Bad Idea" to me.

What's the real issue? Is it that the original coder refuses any comments, or that the OP is a particularly liberal commenter?

In either case, I don't think a technical solution will solve the actual problem. This falls into the same basket as naming conventions, tabs vs spaces, and commit message conventions: You need to figure out something that works for the team.

Your coworker is an idiot and/or doesn't work well others. Don't put up with this.
Vim has folds that can keep large-and-rarely-relevant sections (e.g. the prototypical half-filled Javadoc comment) nicely hidden. His editor may have a similar capability.
I don't like the idea of excluding all comments from the code. However excluding useless or local comments from a repository can be legitimate.

Two potential solutions:

1) Use a regexp to match your comments and trim your code before committing. That shouldn't be too hard, and is pretty efficient since you only need to care about it before submitting your code. If there are existing comments that should stay in the code, use a specific markup for your comments.

2) Another idea could be to maintain a stgit patch integrating all the comments. This requires a bit of process though.