• @[email protected]
      link
      fedilink
      English
      118 days ago

      If there is an alternative through which I can achieve the same intended effect and is a bit more safer (because it will verify that it has len implemented) I would prefer that to commenting. Also if I have to comment every len use of not that sounds quite redundant as len checks are very common

    • @[email protected]
      link
      fedilink
      English
      218 days ago

      There is no guarantee that the comment is kept up to date with the code. “Self documenting code” is a meme, but clearly written code is pretty much always preferable to unclear code with a comment, largely because you can actually be sure that the code does what it says it does.

      Note: You still need to comment your code kids.

    • @[email protected]
      link
      fedilink
      English
      217 days ago

      Comments shouldn’t explain code. Code should explain code by being readable.

      Comments are for whys. Why is the code doing the things it’s doing. Why is the code doing this strange thing here. Why does a thing need to be in this order. Why do I need to store this value here.

      Stuff like that.

    • @[email protected]
      link
      fedilink
      English
      1
      edit-2
      17 days ago

      Better yet, a type hint. foo: list | None can be checked by static analysis, # foo is a list isn’t.