• souperk@reddthat.com
    ·
    8 months ago

    this is a method, and always was a method, I just wanted it to look like an attribute for aesthetic reasons

    I think "aesthetic reasons" is an oversimplification. There are certain assumptions a developer makes when reading some code that uses properties. While these assumptions are not clearly defined and may differ per developer, I think there is a common core.

    (1) There are no side-effects. The object is not mutated (or any other object), no IO takes place.

    (2) The time and space complexity is O(1).

    (3) The result is consistent. Consequent calls to the property should return the same value unless there is a mutation between them.

  • souperk@reddthat.com
    ·
    edit-2
    8 months ago

    (tried to delete this comment but somehow didn't work, I re-read the article and have a different outlook, sorry for the low effort comment)