where do you guys put constants? I've been putting...
# announcements
a
where do you guys put constants? I've been putting them standalone at the bottom of the file, since it feels weird to have them above the class javadoc.
so like
Copy code
/**
 * Stuff
 */
class Foo {
    ...
}

internal const val PREFS_FILE = "somefile"
d
you can use objects and put constants there
i mean companion objects
p
i put them above.. im used it it from ES6 javascript
s
I put them above also
a
I started putting them in companion object when I noticed that having anything outside activity class breaks some features of Android studio, for example the ability to run that activity
m
Depends, if constant is used in one class, i'll use val prefsFile = "somefile" because val is immutable. If need in other class, I use an object to share it. but @adams2 solution seems very nice.