would you place small variable wrapper in a dedica...
# announcements
b
would you place small variable wrapper in a dedicated file?
Copy code
data class Progress(val progress: Int, val max: Int)
it's a function param in one of the services and only two more services will ever have to use it
🚫 5
👌 1
@Adam Powell @Hanno would you mind sharing your opinion why? I'd do the same as I've seen such thing in for example kotlin stdlib but I think that I'll have to discuss it during code review
I'm working with some heavy enterprise architecture addicts that made an interace to something you could call a data class
Copy code
class BasicUserResume(
    val userData: Map<String, String>,
    val resume: InputStream
) : UserResume {
 // some getters and 1 util func
}
a
Spatial locality promotes understanding of related elements and single file per class breaks spatial locality
❤️ 2
It's a habit inspired by Java's language limitations, but most people didn't notice how broken it was because Java classes tend to be long enough that it doesn't look as ridiculous as it does with a Kotlin data class. 🙂
When people write static inner classes in Java, most of the time they're working around this limitation
h
Yea, exactly my thoughts. For people having the java habit, it will be a difficult discussion in a review though, i'm talking from experience, had the same situation :)
a
yep, same. Most people realize there's something worth discussing as soon as they create their first file that's a 30 line copyright header, a one line package declaration and a one line data class 🙂
more concretely, picture the workspace of the people who work on your project. How many code windows/tabs/panes can they see all at once without switching? Being able to see related code on the same screen at the same time helps you hold it all in your head. Hiding it behind multiple files that you have to switch between makes you literally page that information in and out of your working set constantly.