Re:1-star reviews of 'Extreme Programming'
by dbarlett on Thursday December 19, 2013 @12:26PM
(#6936130)
Example from real-world code I've written:
Would you want to debug that without the comment?
[ Parent
| on HN ]
Re:1-star reviews of 'Extreme Programming'
by raverbashing on Thursday December 19, 2013 @05:52PM
(#6938550)
This is a great example of a comment that should (or even must) be there.
If something doesn't work the way it should and it's beyond your control, comment it.
Re:1-star reviews of 'Extreme Programming'
by mpweiher on Thursday December 19, 2013 @12:45PM
(#6936258)
Gladly:
sillyMisspelledDellSOAPIdentifier = "DupilcateAssets"
if i[sillyMisspelledDellSOAPIdentifier] is not None:
Re:1-star reviews of 'Extreme Programming'
by dded on Thursday December 19, 2013 @01:42PM
(#6936731)
But this is largely a comment disguised as a variable name, and is no more or less likely to stay up-to-date as a comment. If the Dell Identifier were to ever be changed to "DuplicateAssets", you're just as likely to have
sillyMisspelledDellSOAPIdentifier = "DuplicateAssets"
as the original might have if i["DuplicateAssets"] is not None: # Not a typo...
And your method replaces one line of code with two.Comments have problems, but they solve problems too. They're not evil.
Agreed - I'd really appreciate coming across that one. It probably isn't the definitive example I'm looking for though.
Re:1-star reviews of 'Extreme Programming'
by aerique on Thursday December 19, 2013 @02:06PM
(#6936959)
Why not just:
if i["DupilcateAssets"]
is there some Python subtlety I am missing?In python some things evaluate as false in an if or boolean conversion (0, an empty list/tuple/set/dict/user_defined, an empty string "", and more). None evaluates as false as well, but is still distinguishable from the rest.
In ruby you likewise sometimes need to use object.nil? because nil and False are both "false-ish".