Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 5
    Aside: I would change the second example to if (set(...).contains(prop)) Commented May 5, 2020 at 11:04
  • 11
    Any code whose intention requires explanation about why you're doing it to someone reading or reviewing it the code seems undesirable to me. You've mentioned that your intention is to make the code more generic and easier to use, but even with that explanation I have to say I still don't understand what the point is, and honestly can't see how it makes the code more generic or easier to use. Maybe I'm just not smart enough to understand, but then it's often a good idea to assume your audience isn't very smart and keep in mind the Principle of least astonishment. Commented May 5, 2020 at 11:17
  • 1
    In fact, I'd say if your only reason for doing that is to communicate to other developers, then a far more direct and less cryptic way of doing that would be to add a comment which lays out your intention explicitly - for example /* Add new conditions here */ Commented May 5, 2020 at 11:21
  • 3
    I would not recommend it. It always provokes a WTF by the next maintenance programmer. Commented May 5, 2020 at 12:03
  • 2
    For SQL alignment and debugging purposes it's also common to write WHERE 1 = 1 ..., WHERE 1 = 0 ... respectively. Commented May 5, 2020 at 12:31