Avoid using companion objects. Behind the hood, getter and setter instance methods are created for the fields to be accessible. Calling instance methods is technically more expensive than calling static methods.
public class DbConstants {
companion object {
val TABLE_USER_ATTRIBUTE_EMPID = "_id"
val TABLE_USER_ATTRIBUTE_DATA = "data"
}
Instead define the constants in object
.
Recommended practice :
object DbConstants {
const val TABLE_USER_ATTRIBUTE_EMPID = "_id"
const val TABLE_USER_ATTRIBUTE_DATA = "data"
}
and access them globally like this:
DbConstants.TABLE_USER_ATTRIBUTE_EMPID
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…