▲ | aleph_minus_one 4 days ago | |||||||
> Because adding a new line at the end of the table (1) requires editing 1 line, instead of 2 (2) makes the diffs in code review smaller and easier to read and review. This judgement is rather based on a strong personal opinion (which I don't claim to be wrong, but also not as god-given) on what is one, and what are two changes in the code: - If you consider adding an additional item to the end of the list to be one code change, I agree that a trailing comma makes sense - On the other hand, it is also a sensible judgment to consider this to be a code change of two lines: 1. an item (say 'peach') is added to the end of the list 2. 'orange' has been turned from the last element of the list to a non-last element of the list If you are a proponent of the second interpretation, the version that you consider to be non-advantageous is the one that does make sense. | ||||||||
▲ | dghf 4 days ago | parent | next [-] | |||||||
> 2. 'orange' has been turned from the last element of the list to a non-last element of the list Then why not consider it four changes? 3. 'banana' has been turned from the last-but-one element of the list to the last-but-two element of the list 4. 'apple' has been turned from the last-but-two element of the list to the last-but-three element of the list | ||||||||
| ||||||||
▲ | Skeime 4 days ago | parent | prev | next [-] | |||||||
But the second interpretation only makes sense if the last item somehow deserves special treatment (over, say, the second-to-last item). Otherwise, you should similarly argue that the previous second-to-last item should also show up in the changes as it has now turned into the third-to-last item. (So maybe every item in the list should be preceded by as many spaces as are items before it and succeeded by as many commas as are items following it. Then, every change to the list will be a diff of the entire list.)
In my experience, special treatment for the last item is rarely warranted, so a trailing comma is a good default. If you want the last item to be special, put a comment on that line, saying that it should remain last. (Or better yet, find a better representation of your data that does not require this at all.) | ||||||||
| ||||||||
▲ | 4 days ago | parent | prev [-] | |||||||
[deleted] |