Sample Code
This page describes code samples that might be useful, either when learning Kotlin or figuring out a technique for your application.
⚠️
If you use any code samples from here or elsewhere, make sure that you abide by our code policies. Make sure to acknowledge your sources!
Course Repositories
We maintain public repositories in GitLab. The following projects are available:
- demos/*: full applications (console and desktop), with issue lists, documentation etc.
- kotlin-language: Kotlin language examples. Used in lectures.
- sample code: smaller, limited applications used to demonstrate specific functionality e.g., database connections, UI dialogs. Grouped into desktop/android folders based on platform.
- templates: project documents e.g., meeting minute templates.
To get a copy, git clone
the URL for the repository that you want to open. This command, for instance, would create a copy of the kotlin-language
project in a directory of the same name.
$ git clone https://git.uwaterloo.ca/cs346/kotlin-language.git
The sample code
folder contains code to accompany the lecture slides.
External Repositories
This is a mix of tutorial links and code repositories.
Kotlin Code
- Atomic Kotlin Exercises: Exercises to accompany the Atomic Kotlin book.
- Kotlin Programming Language. GitHub repo for the Kotlin project.
- Kotlin-Algorithms-and-Design-Patterns. Algorithms and design patterns.
Kotlin Multiplatform Code
- kmm-basic-sample. Cross-platform mobile application.
- my-bird-app. Cross-platform mobile with Compose.
- John O’Reilly’s KMP samples. Many samples, some of which are included in the official Kotlin KMP repo.
- Ktor codeSnippets. Networking with Ktor.
- Exposed Samples. Databases with Exposed.
Compose Code
- Compose Multiplatform Repo. Desktop applications for macOS, Windows, Linux.
- Compose Charts Desktop. Simple plots.
- Compose Color Picker. Graphical colour chooser.
- Jetpack Compose for Android Developers. Google code path.
- Jetpack Compose Repo. Mobile applications for Android.
- State in Jetpack Compose. Advanced code lab.
Cloud Computing
- Google Cloud Platform Kotlin Samples. Official samples.
- How to Publish a Ktor Docker Image to Container Registry Using the Ktor Plugin. Publish from your IDE.
- Serverless Kotlin on Google Cloud Run. Getting a Ktor service running in the cloud.
Final Word
