views:

55

answers:

3

Line numbers are great in the IDE when you are working with compiler errors - but they degrade overtime. In other words they change when code is added/removed/refactored and the line number that was used in a code review or stack trace may be in the wrong place.

Is there an alternative to using line numbers to identify specific lines of code which does not degrade over time?

+3  A: 

Changeset/revision number from your source control system + line numbers should do it.

If the code you are meant to review "degrade over time", then perhaps you should refactor it to avoid all the changes changing the same piece of code all the time? It's a bit hard to do code reviews if the code you originally intended to review is no longer there.

Or, you should speed up the review process...

Lasse V. Karlsen
+1 that is what we are currently doing, was hoping for something that would persist across revisions and track correctly.
Robert MacLean
The only way to do that is to just put tags into the code, which I wouldn't recommend. Another alternative would be to get a snapshot of the code piece in question, and try to apply some pattern matching to find the corresponding piece, but again, I wouldn't recommend it.
Lasse V. Karlsen
A: 

Learn to use tools in your IDE most have a shortcut for goto line.

To reference a line for code review use a combination of revision and line number as already suggested.

Andrew
+1  A: 

Refactor your code. Then you can reference the method and the operation within that method.

ck