• olafurp@lemmy.world
    link
    fedilink
    arrow-up
    16
    arrow-down
    6
    ·
    29 days ago

    Using classes is nice tbh. Using inheritance usually isn’t. Inheriting from inherited class should be forbidden.

    • lseif@sopuli.xyz
      link
      fedilink
      arrow-up
      1
      ·
      28 days ago

      Inheriting from inherited class should be forbidden.

      so an interface with state?

      • olafurp@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        28 days ago

        Those are nice. Services that manage data are an example. Having the class also declare how to interact with the data is nice.

        My most OOP pattern I like using is implementing an interface with an abstract class for “standard” implementation. Then implement abstract methods for a concrete thing.