Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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!


Another life hack: reference the same “AB-20200405” in the other code snippet.


Right, it all falls apart otherwise.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: