• xigoi@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      4
      ·
      edit-2
      19 天前

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

      • Traister101@lemmy.today
        link
        fedilink
        arrow-up
        2
        ·
        20 天前

        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