Random idea: When removing the `package` directive...
# language-proposals
m
Random idea: When removing the
package
directive from all Kotlin files of a project then a compiler option allows specifying the same package name for all Kotlin files instead of using the root package. So I can stop repeating myself.
d
If you use a directory structure that adheres to the package names, the IDE takes care of the packages for you, including refactorings.
However, if you follow the coding style guide point of not having directories for
com/github/yourname/projectname
(using the root directory for this package), I don't believe the IDE plays very nicely.
That aside, I think it's an interesting idea. The compiler should be able to infer the package name from the directory containing the file, and optionally a root package name (allowing you to conform to the style guide point I mentioned above)
m
I stopped using multiple package names and package-based folder structure a while ago and use the module-based thinking of Swift. Drowning in packages for me is Java history and when I feel the urge to have more than one package it’s probably time to split the module into submodules or rethink my architecture. Indeed some functionality of IDEA doesn’t work so well yet in that case, e.g. refactoring. Anyway, I’d like to stop thinking about packages except once when setting up a new module 🙂 So having the classes set to the right package automatically would make that even easier!
d
+1 from me
I think there's a point where a project has enough modules that splitting code up into more modules instead of packages is cumbersome
but I've never tried it