Effective Kotlin: Item 22 — Use interfaces only to define types

In item 22 of Joshua Bloch’s famous book Effective Java he concludes that interfaces should only be used to define types and not to merely export constants. The following example shows the constant interface anti-pattern, i.e. what not to do:

public interface PhysicsConstants {
static final double ELECTRON_MASS = 9.109_383_56e-31;
}

In Java there are two approaches, use an enum type (item 34) or a non-instantiable utility class (item 4). Using Kotlin’s Object declarations is one way to create…