views:

103

answers:

8

Do you compile your code before committing it to the repository, even when you only change a few comments? I know comments are typically ignored by compilers, but I find myself doing this often out of habit.

+10  A: 

It's good practice to compile the code every time prior to commit. Sometimes you accidentially edit something except the comments and thus break the code. Compiling is usually very quick and helps avoid needless pain. That's why I try to compile every time prior to commit.

sharptooth
Additionally, if any documentation is generated based on comments content, it is a good idea to check this too. For example, some of documentation where I work is generated from module comments and function header comments--each have its set of tags that the document generator expects.
Sparky
+1  A: 

I commit to git and then push my changes to an svn server everyone else uses, so I have a script that automatically rebuilds and runs tests and pushes to svn if everything passed

Michael Mrozek
A: 

I can see why someone might not want to go through a compile cycle if it takes five minutes. But if that's the case, maybe you can collect all of your changes into a single compile/commit operation.

Robert Harvey
+1  A: 

Every Commit Should Build the Mainline on an Integration Machine

CodeToGlory
How does that answer his question? We do that too, but that doesn't stop me from building on my machine before I commit
Michael Mrozek
If there are no environmental differences between developer machines, people should do an update and build before they commit and that involves comments and ultimately if you choose or forgot to build then your continuous integration will catch if there is a problem
CodeToGlory
+2  A: 

I always compile before committing, the working compiled assembly should always match the working source code. In practice, you don't need to compile if you're just changing comments. But how often are comments the only thing you would change?

Remember, in .NET you can add XML comments which the compiler may read to create assembly documentation. Obviously when changing these types of comments a compile would need to be done.

David Neale
You commit your compiled assembly to version control?
Stephen
Sorry, badly worded. Will amend.
David Neale
"But how often are comments the only thing you would change?"I like to fix typos in comments or update comments that are not in sync with the corresponding code. I feel like this is important so in the future other developers don't have to waste time being confused by incorrect comments.
jbgo
+1  A: 

e.g. in .Net, you could mess up the XML-comments and check in an unnecessary compiler warning if you are careless. So it's a good idea to compile your code every time prior to commit (as it is to run your tests before committing).

dkson
A: 

And any half decent compiler will take almost-zero time to recompile code when only comments have changed. The first parser pass should notice that no functions have changed and stop.

Martin Beckett
A: 

From personal experience, an overworked brain has tendency to key in more than just comments and not notice it. It is probably just better to compile it even if it takes a while. Will save others the headache and protect your credibility.

neoblitz