Hacker News new | ask | show | jobs
by aaronbrethorst 2268 days ago
Explanatory comments that tell the reader to go look for other instances of this pattern are the key to success.

    // AB-20200405 - Hi future developer (probably me),
    // if you're copying and pasting this code, then
    // please take an extra five minutes to locate the
    // other similar instance of this code snippet in
    // the codebase, and refactor both of these into a
    // method first. The other snippet will have the
    // same comment that precedes this one.
    // 
    // Here's what this overly clever snippet of code 
    // is doing, so that when you do refactor it into a
    // method in 2023, you don't miss an important edge
    // case. Ta!
1 comments

Another life hack: reference the same “AB-20200405” in the other code snippet.
Right, it all falls apart otherwise.