• Fiery@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    2
    ·
    1 day ago

    Functional programming fixes the problem by simply not making it OO anymore, and while I’m personally a big fan of the paradigm there are situations where an OO approach is preferable (or even only to conform to a project’s existing way of doing things).

    • Kogasa@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      1 day ago

      What I described isn’t necessarily functional. This is just a principle for ensuring objects represent clear and well-defined contracts. The idea is that to mutate something, you should own it; that means interfaces / public APIs, which can be called externally, should take immutable arguments. You can still mutate instance members internally because those are owned by the instance. If mutation is really necessary between two objects then it should be coordinated by an object owning them both.