DEV Community

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

Collapse
 
martinhaeusler profile image
Martin Häusler

Thanks for sharing your experience. This way of formatting improves the situation a little. However, for me it's still counter-intuitive. When I open up the source code of a class file, there are three things that I am primarily interested in:

  1. what kind of class is it? (regular class, interface, enum...)
  2. what's the name of the class?
  3. what is the base class, and what are the interfaces?

While the "Kotlin way" satisfies 1 and 2, it fails on 3. Look where the base class is located. Somewhere way down there. The very concept of declaring fields (which belong to the class) within a constructor is appalling to me. A constructor is a member of a class. Why should it contribute to the structure of the class (in terms of fields in this case)? I realize that this is not really the case, but the syntax makes it look as if that was happening. Maybe it's just because I've written so much Java and C#.