Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
freddo ( freddo@feddit.nu )  to Programmer Humor@programming.devEnglish · 23 days ago

OOP at home:

feddit.nu

message-square
25
link
fedilink
197

OOP at home:

feddit.nu

freddo ( freddo@feddit.nu )  to Programmer Humor@programming.devEnglish · 23 days ago
message-square
25
link
fedilink
  • tatterdemalion ( tatterdemalion@programming.dev ) 
    link
    fedilink
    arrow-up
    51
    ·
    23 days ago

    In over ten years of professional programming, I have never used inheritance without regretting it.

    • AudaciousArmadillo ( AudaciousArmadillo@piefed.blahaj.zone ) 
      link
      fedilink
      English
      arrow-up
      13
      ·
      23 days ago

      It works great for technical constructs. E.g. A Button is a UI element. But for anything business logic related, yeah it’ll suck.

    • Valmond ( Valmond@lemmy.dbzer0.com ) 
      link
      fedilink
      arrow-up
      3
      ·
      23 days ago

      That’s wild. What did you use it for?

      • tatterdemalion ( tatterdemalion@programming.dev ) 
        link
        fedilink
        arrow-up
        2
        ·
        21 days ago

        Some legacy Python code that already used inheritance. I had to extend it, and it was pretty infeasible to refactor the whole thing to not use inheritance. Not sure if I technically regretted that decision, but it was definitely painful, since Python inheritance makes it really hard to follow program control flow.

        • Valmond ( Valmond@lemmy.dbzer0.com ) 
          link
          fedilink
          arrow-up
          1
          ·
          21 days ago

          Non typed inheritance, what could go wrong eh. You can just ‘add’ a function to a class dynamically in python, that is so bad.

          Done any C++ classes & inheritance?

          • tatterdemalion ( tatterdemalion@programming.dev ) 
            link
            fedilink
            arrow-up
            1
            ·
            20 days ago

            It was actually typed. Python had type annotations at the time.

            I only wrote C++ very early in my career so I don’t remember much, but I’m sure I at least tried some inheritance in toy games I would write. All of that code was trash though by my standards today.

            • Valmond ( Valmond@lemmy.dbzer0.com ) 
              link
              fedilink
              arrow-up
              1
              ·
              19 days ago

              Still does, but you don’t have to.

              So you haven’t had much experience with oop?

              • tatterdemalion ( tatterdemalion@programming.dev ) 
                link
                fedilink
                arrow-up
                1
                ·
                18 days ago

                I have used OOP design patterns many times, but that doesn’t mean I use inheritance a lot. I almost always reach for interfaces instead.

                • Valmond ( Valmond@lemmy.dbzer0.com ) 
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  18 days ago

                  Well then I understand why inheritance isn’t your thing, I yet have to see an interface in need of inheritance.

    • kalpol ( kalpol@lemmy.ca ) 
      link
      fedilink
      arrow-up
      3
      ·
      21 days ago

      This applies to firewall rules too

    • Supercrunchy ( Supercrunchy@programming.dev ) 
      link
      fedilink
      English
      arrow-up
      3
      ·
      23 days ago

      It might be nice to use in some very specific cases (e.g. addition-operation is a binary-operation AST node which is an AST node).

      In most of the cases it just creates noise though, and you can usually do something different anyway to implement the same feature. For example in rust, just use enums and list all the possible cases and it’s even nicer to use than inheritance.

    • wewbull ( wewbull@feddit.uk ) 
      link
      fedilink
      English
      arrow-up
      1
      ·
      22 days ago

      Do you include “traits” and “interfaces” under the title “inheritance”?

      • tatterdemalion ( tatterdemalion@programming.dev ) 
        link
        fedilink
        arrow-up
        1
        ·
        21 days ago

        No because those are different things.

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 760 users / day
  • 2.16K users / week
  • 3.86K users / month
  • 8.64K users / 6 months
  • 454 local subscribers
  • 30.2K subscribers
  • 1.27K Posts
  • 20.7K Comments
  • Modlog
  • mods:
  • Feyter ( Feyter@programming.dev ) 
  • adr1an ( anzo@programming.dev ) 
  • BurningTurtle ( BurningTurtle@programming.dev ) 
  • Pierre-Yves Lapersonne ( pylapp@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code