News for hackers. Stuff that matters.
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:

  if tag in tag_list:
    data[u"Tag"] = tag
    try:
      if i["DupilcateAssets"] is not None:  # not a typo - misspelled in Dell SOAP response
        data[u"Error"] = "Duplicate assets returned"
Would you want to debug that without the comment?
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.

Re:1-star reviews of 'Extreme Programming' by rch on Thursday December 19, 2013 @12:45PM (#6936256)
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?
Re:1-star reviews of 'Extreme Programming' by cma on Thursday December 19, 2013 @03:09PM (#6937467)
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".

Re:1-star reviews of 'Extreme Programming' by jheriko on Thursday December 19, 2013 @01:00PM (#6936362)
some comments are very useful, this is a great example