• 4 Posts
  • 468 Comments
Joined 1 year ago
cake
Cake day: July 7th, 2023

help-circle






  • Because you’re assuming foo won’t be renamed when it becomes a function. A function should start with a verb, say get_foo(), because just foo() tells me nothing about what the function does (or what to expect as output). If you make it a property, get_ is implicit.

    So if the age is computed from the year of birth for example, it’s really e.g. thing.age or thing.get_age() - both of which are fine, but I’d pick the property version.










  • Eager Eagle@lemmy.worldtoProgramming@programming.devWhy YAML sucks?
    link
    fedilink
    English
    arrow-up
    11
    arrow-down
    5
    ·
    edit-2
    4 days ago

    YAML sucks because, among other things, indenting it is not obvious.

    In contrast, the only mistake of Python when it comes to whitespaces was allowing hard tabs, which makes it too easy to mix them if your editor is not configured.

    Improper indentation stands out more than missing or unbalanced braces and it’s really not an issue to delimit code blocks.


  • Eager Eagle@lemmy.worldtoProgramming@programming.devWhy YAML sucks?
    link
    fedilink
    English
    arrow-up
    15
    arrow-down
    7
    ·
    edit-2
    4 days ago

    False dichotomy. Optional braces are bad practice because they mislead the programmer that is adding an additional clause to the block.

    This misleading behavior wouldn’t happen in Python, as it would either be invalid syntax, or it would be part of the block.

    Indentation problems are pretty obvious to the reader. Even more than missing or unbalanced braces.