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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.