Live data from Hacker News

The Last Line Effect

viva64.com

1–10 of 27 posts

Re: The Last Line Effect

#3
This is really interesting. I just looked over some code I wrote this morning. There were 2 LLE errors. I'm sure I would have caught them in testing after lunch but, woah. For the life of me, I can't reconstruct my mental state when I edited those code bits though, so I don't know what the root of the error is. I think now though, I'll be on the lookout and perhaps gain some insight.

In retrospect, I've had quite a few of these - once pointed out as a pattern, it's fairly easy to see it's a "thing".

I wonder what sort of IDE or other tooling could be put in place to hint those errors out of existence.

Re: The Last Line Effect

#4

This is really interesting. I just looked over some code I wrote this morning. There were 2 LLE errors. I'm sure I would have caught them in testing after lunch but, woah. For the life of me, I can't reconstruct my mental state when I edited those code bits though, so I don't know what the root of the error is. I think now though, I'll be on the lookout and perhaps gain some insight. In retrospect, I've had quite a f…

Maybe the IDE could highlight what you have not changed after duplicating a line, like an inline diff.

Re: The Last Line Effect

#5
I'm not convinced that this is necessarily caused by people losing attention while they write the last line due to anticipation of finishing the task. Other possible theories I can think of:

* People make mistakes in any line, but they often unconsciously review them and spot the mistake while they're writing the next line. In the case of the last line there's no such automatic review.

* (plausible in some of the examples, not all of them) The last line was added by copy–paste at a later date than all the others.

Re: The Last Line Effect

#6

This is really interesting. I just looked over some code I wrote this morning. There were 2 LLE errors. I'm sure I would have caught them in testing after lunch but, woah. For the life of me, I can't reconstruct my mental state when I edited those code bits though, so I don't know what the root of the error is. I think now though, I'll be on the lookout and perhaps gain some insight. In retrospect, I've had quite a f…

In case you don't know: the site in question is from a company that makes a static analyzer that spots such issues.

Re: The Last Line Effect

#7
In my experience this effect is real, but I wouldn't always see it in the last line. A coworker proved this to me years ago by making me keep a tally when errors were caused by copy-and-pasted code, versus all other causes. Copy-and-paste won hands down.

Re: The Last Line Effect

#8
This is potentially an interesting effect and worthy of some consideration, but the analysis needs to include some regression of this possible factor:

An increased number of errors on "return" lines.

Which naturally should be more frequently last lines than otherwise.

Re: The Last Line Effect

#9
Sometimes copy paste is unavoidable, but a lot of times it can be replaced with a loop over a constructed array of "things that change" that achieves the same goal. I've been trying to do this recently in the spirit of DRY; it has the side benefit of often making the code quite a bit more readable.

Re: The Last Line Effect

#10
The last line often has something extra - a semicolon or parentheses - or something missing, like no comma in an enum or no `&&` in a long chained conditional. Maybe that triggers the "gorilla on the basketball court" effect, and we miss the error in the meat of that line because we're focusing on the difference.
Post reply on HN