androidpackage-name

What is the Naming Convention of sub-packages of the Android Studio Projects? (MAD)


I have been around for a short time and has always been questioning about the best practices for naming sub packages for an android project.

Suppose I have the sub packages to be named from two or more words. What will be the best industry standard practice to name it?

Should I use like,

For "User Auth":

userauth or,
userAuth or,
user_auth or,
user-Auth ?

For "Now Playing":

nowplaying
now_playing
now-playing
nowPlaying


For "Feature Chart Flow":

featurechartflow
feature_chart_flow
feature-chart-flow
featureChartFlow

Solution

  • The naming conventions for Kotlin suggest the following:

    Names of packages are always lowercase and do not use underscores (org.example.project). Using multi-word names is generally discouraged, but if you do need to use multiple words, you can either just concatenate them together or use the camel case (org.example.myProject).

    So in your case, when your package name can't be reduced to a single word, use concatenation or camelCase:

    userAuth
    userauth
    nowPlaying
    nowplaying
    featureChartFlow
    featurechartflow
    

    You should however try to only use a single word as package name. You could for example use auth instead of userAuth.
    You can also consider to restructure your application and split the packages:

    auth
    ├── user
    │   ├── ComposableA.kt
    │   └── ComposableB.kt
    ├── admin
    │   ├── ComposableX.kt
    │   ├── ComposableY.kt
    │   └── ComposableZ.kt