3 ms·
> Up until recently, I've enjoyed the builder pattern. It becomes a pain in the ass though when your objects are deeply nested. That and good luck adding a new
by mercurial 12y ago
> Up until recently, I've enjoyed the builder pattern. It becomes a pain in the ass though when your objects are deeply nested.
That and good luck adding a new required field in your "constructor", because you just gave up on statically checking the parameters of the "constructor".
- mercurial 12y agoCan't say I understand the downvotes on this one. If you add a parameter in a traditional constructor but don't update the site calls, your code won't compile. If you add a builder method, your code will still happily compile, you'll have to wait until runtime to get an exception, if you added a check in the build() method. That's something to think about, just like you give up safety for convenience when you move to a DI framework.