Re:Case against OOP is understated, not overstated (2020)
by native_samples on Friday February 11, 2022 @02:31PM
(#30305978)
But the concept of a factory is independent from whether you name it. In Java you can write a factory like this:
Behind the scenes it's a class, but you don't write it as such and you don't name it. Nonetheless, it's still a factory.
[ Parent
| on HN ]
Re:Case against OOP is understated, not overstated (2020)
by agumonkey on Friday February 11, 2022 @03:04PM
(#30306346)
It's vacuous concept.
Also you're leveraging anonymous function syntax which is, interesting, to say the least. In Java 8- you'd have to write boilerplate class named after a pattern. Lastly creating something from outside information was done since forever, it's trivial when you don't invent ceremony around it. Hence my conclusion, it's a waste of time and effort.
Re:Case against OOP is understated, not overstated (2020)
by native_samples on Saturday February 12, 2022 @08:03AM
(#30312461)
No, because you still need to name the thing the function is assigned to. What exactly should the user of the function call it? thingMakingFunction? You need a consistent way to refer to "a function call that creates an object in a particular state" and factory is as good a word as any.
Yes, in Java 7 or below it'd have required more verbose syntax. So what? That came out 8 years ago and Java isn't the only OO language with a notion of factories. C# had delegates much longer than Java had lambdas, and it also needs a way to talk about "a bit of code that produces objects complying with a contract", so also talks about factories.