re: Gang of Four Patterns in Kotlin VIEW POST

re: Really good post. short and clean - like as a Kotlin style ;) But i think builder could be opened more. Your example is good, but i mean the using ...

Using apply for post constructor changes is nice but I wouldn't call it a builder. With the approach you are describing an instance is created first, with empty constructor, and then modified in the apply{} block. This means that

  1. Default values are required

  2. It is not possible to ensure that an instance exists only if the parameters are valid

code of conduct - report abuse