4 ms·
So would you say there is never a use case for something like builder pattern? I feel like at least for readability builder patterns can be very nice (Take bla
by ivalm 6y ago
So would you say there is never a use case for something like builder pattern? I feel like at least for readability builder patterns can be very nice
(Take blah then do a then do b then do c then do d then return the result which is if same type as blah).
The functional approach basically moves “blah” all the way to the right.
In terms of mocking builder methods are just as simple (since they return the class rather than modify in place).
(Concretely I am think of something like transformations on dataset, especially if you do different transformations/in different order at different places in code)
- mlthoughts2018 6y agoThe trouble with builder pattern is that it basically introduces a new concept (the builder class and any class hierarchy of builders), purely for the sake of constructor functions. The constructors that live in builder classes can just be separate module functions, attached to no class, and use decorators or other non-object-oriented types of metaprogramming to add specializations. It’s very nice to encapsulate complex creation in a helper function, but builder pattern just takes this idea and adds unnecessary code bloat.