• Serinus@lemmy.world
    link
    fedilink
    arrow-up
    34
    ·
    6 days ago

    OOP is great, and can be much simpler than what you’ve seen.

    It’s Java culture that’s terrible. The word “Factory” is a code smell all on its own.

    Just like any tool, don’t overuse it. Don’t force extra layers of abstraction.

      • xigoi@lemmy.sdf.org
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        4 days ago

        It means you’re compensating for the lack of optional/named parameters in your language.

        • Traister101@lemmy.today
          link
          fedilink
          arrow-up
          2
          ·
          5 days ago

          Eh? How’s that work. I’m not going to sit here and say there isn’t too many factories in Java but as a concept it’s extremely useful. You hand off a “factory” to something which actually creates the object. This is really useful in for example serialization. How so? You could register factories (mapped to some sort of ID) which get passed the serialized data and return some sort of created object. Now the core serialization code doesn’t know nor care how exactly any particular type gets serialized. Pretty nifty huh?

          Some languages have better ways to encapsulate this functionality but that’s what the factory concept is