re: Gang of Four Patterns in Kotlin VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I agree for this particular example, but consider a class with more properties. You generally don't want a constructor (or any other method) with ...
 

I think one of the problems with your approach is theoretically possibility to have broken data, since constuction of object is separated from setting up field.

Approach with naming constructor parameters or more stable and looks like builder, since all preparations are happen in constructor of object. And if it will fail, you just will not receive a new object.

Sure, but separating construction from representation is the whole point of the Builder pattern.

code of conduct - report abuse