https://kotlinlang.org logo
#getting-started
Title
# getting-started
t

tseisel

08/11/2020, 4:54 PM
Is there any convention for package names ? Should we stick to Java conventions (for example
reverse.domain.name.myapp.mymodule
), or is it possible to use shorter names such as
myapp.mymodule
?
n

nanodeath

08/11/2020, 5:02 PM
two things to consider: 1. Kotlin doesn't force you to match the package name to the actual path of the file, buut...IMO they should be consistent. if it's
com.company.foo
, it should be in
com/company/foo/
directory. (though as I said, doesn't have to be) 2. Kotlin's
internal
is moderately different from package private, which if anything means you can create more packages internally without making everything be public. as for your actual question...I'd still namespace it by domain.
f

Fabio

08/12/2020, 12:13 AM
that said I think we fall into the good practices of if you're not coding for java, it's still ok to be nice and be compatible with it in case someone else wants your code.
a

araqnid

08/12/2020, 9:40 PM
Istr the JB convention is to remove the trailing empty directories from the source paths (so if a top-level class is com.example.thing.Main that’s in src/main/kotlin/Main.kt and com.example.thing.util.Utils would be in src/main/kotlin/util/Utils.kt)
I have memories of encountering Scala classes at work called “util.Error” … of course, multiple conflicting versions of this made its way into internal libraries eventually
6 Views