# Kotlin Code Organization

DevFeed: [Kotlin Code Organization](<https://devfeed.tech/articles/kotlin-code-organization-29359.md>)

Original publisher: [Read original article](<https://arturdryomov.dev/posts/kotlin-code-organization/>)

Author: Artur Dryomov

Published: 2020-01-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Artur Dryomov](<https://devfeed.tech/sources/artur-dryomov.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [systems](<https://devfeed.tech/topics/systems.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Maven](<https://devfeed.tech/topics/maven.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [unit tests](<https://devfeed.tech/topics/unit-tests.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [maven](<https://devfeed.tech/tags/maven.md>), [organization](<https://devfeed.tech/tags/organization.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>)

## AI overview

This tutorial explains how to organize Kotlin code using standard directory layouts and source sets. It recommends separating production and test code, grouping files by language and tooling, storing Kotlin files in Kotlin-specific directories, and organizing extension functions by their target class and package.

## Source excerpt

What's the motivation behind organizing the code? Two points come to mind. Help humans. Consistent environments are easier to understand and adapt. Storing the source code in src/ instead of _k_/ makes it easier to find. Help machines. Build systems need hints. The code in main/ should be assembled all the time, while test/ is test-specific and shouldn't make it to a production environment. Sounds empathic. Where do we start?