You are currently viewing Best practices for packages

Best practices for packages

tl/dr; First real project with kotlin, wondering for best practices for code organization.

Hi there, I’m working on my first Kotlin project (coming from Java).

The system is pretty basic, right now all I have is a couple of data classes (value objects) with the corresponding repositories.

For those I have two files, model.kt and repositories.kt.

Back in Java (with the one file one class rule) I would make a model package and a persistence package. Trying to keep that sense of order I have made the packages, but there’s a single file on each with multiple (simple) classes. (Each of those have 20 lines or less).

Right now I feel that the packages (as a directory structure) are not needed, but having all my files on the root directory feels wrong. But, again, I don’t know if that’s just some kind of stockholm syndrome.

Any suggestion will be appreciated.

submitted by /u/d3249
[link] [comments]