4 ms·
I think you're thinking of the Builder pattern. That's a bit different, because you return the same type and same object on every chained call.
by jacques_chester 3y ago
I think you're thinking of the Builder pattern. That's a bit different, because you return the same type and same object on every chained call.
- iainmerrick 3y agoNo, I think it is the same thing. Typically¹ with a Builder there's one final method that builds and returns the final object (which has a different type). ¹ Edit to add: well, it's a pattern I've seen a lot, anyway. I think it's preferable to mutating the final object in place because it "makes illegal states unrepresentable" as others in this discussion have mentioned.