DEV Community

Discussion on: Kotlin - The Good, the Bad and the Ugly

Collapse
 
eric_wilson_644bcce9ac4eb profile image
Eric Wilson

Great article! And some nice responses. It sounds like Kotlin was designed to make it harder to do what some people consider bad practices, such as inheritance and the use of static functions. Thank you for pointing that out. I have run into problems with inheritance in the past, so if it is harder in Kotlin, that is okay with me. Regarding defining fields in a constructor, to me that is not a problem, it is a time saving feature, similar to data classes. In TypeScript you can define fields in the constructor and it saves a lot of work. For example (TypeScript):
class TestClass {
constructor(private name: string) { }
}

I am new to Kotlin. Does it force you to initialize all fields in a constructor? If so, I think that is a good idea to prevent bugs.