String (…) ) public final class TokenInfo { private final String tokenType; private final String identity; (…) public TokenInfo( String tokenType, String identity, (…)) { this.tokenType = tokenType; this.identity = identity; (…) } public final String getTokenType() { return tokenType; } public final String getIdentity() { return identity; } }
String (…) ) public final class TokenInfo { private final String tokenType; private final String identity; (…) public TokenInfo( String tokenType, String identity, (…)) { this.tokenType = tokenType; this.identity = identity; (…) } public final String getTokenType() { return tokenType; } public final String getIdentity() { return identity; } }
= "auth", val identity: String, val expiration: Int? = null ) val token = TokenInfo(identity = "xxx") Immutable classes with optional fields? Constructors with lots of parameters Builder object
String (…) ) public final class TokenInfo { (…) public String toString() { (…) } public int hashCode() { (…) } public boolean equals(Object var1) { (…) } public final TokenInfoId copy(String tokenType, String identity) { (…) } public final String component1() { (…) } public final String component2() { (…) } } Immutability made easier
Null checks are a small runtime overhead • Platform and base libraries are the sane • Kotlin library overhead not important for backend Can affect Performance ® BUT... (2)
// Translated to: public static final class Constants { companion object { const val TWO = 2 // MyObject(2) NO OBJECTS ALLOWED // Translated to: inlined val THREE = MyObject(3) // Translated to private static // + Companion class with getter @JvmField val FOUR = MyObject(4) // Translated to public static final } } Constants: too many options? https://blog.egorand.me/where-do-i-put-my-constants-in-kotlin/
• Eclipse incremental compilation a bit slow • Some crashes when updating IntelliJ plugin • Incremental build disabled by default in some versions Maven+Gradle • Checkstyle, Findbugs… Tooling problems?
• Eclipse incremental compilation a bit slow • Some crashes when updating IntelliJ plugin • Incremental build disabled by default in some versions Maven+Gradle • Checkstyle, Findbugs… Tooling problems?