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*

9
  • 5
    Does one really need to go to that much trouble to avoid a ""? In the context of comparison what else could a blank string mean? Commented Aug 23, 2018 at 17:57
  • 2
    you say "not_filled_in" is more descriptive than "empty_string" ? I say you are high. Commented Apr 15, 2019 at 6:20
  • 13
    I would disagree with that answer. Magic numbers are bad, that makes sense. Magic values in general as well. But "" is not a magic value, same as True, False or None aren't magic values. Commented May 24, 2019 at 8:47
  • 4
    @firelynx how much more explicit explicit can you get to say "this string is empty" than to use ""? Would you also redefine True as REALLY_TRUE? In the end you will end up with a lot of variables (that are non-constant compared to a literal "") that say the same thing. So, is CSV_NONE different to JSON_EMPTY_VALUE? The problem then occurs when you transfer between different parts of the program. Then you might not know anymore if you have a None or a "", especially if you name your constants something misleading like CSV_NONE, which is actually not None but "". Commented May 27, 2019 at 7:54
  • 3
    @firelynx This causes more ambiguity than just use the constant values None, True, False or "". Using variables instead of magic values is useful whenever you encode more information in the name then what the value itself already has, e.g. use STATE_A instead of 27. Or whenever there is ambiguity, e.g. GPIO.HIGH instead of 1, because depending on the logic you use, 1 could be HIGH or LOW. But in the given example using a variable causes more harm than good. Commented May 27, 2019 at 8:01