Published using Google Docs
kotlin
Updated automatically every 5 minutes

Kotlin Fundamentals

This course covers the Kotlin programming language and some of its more important APIs. This course focuses on the core part of Kotlin, and provides its participants with the required knowledge and practical experience required for using this relatively new programming language in a practical way.

This course was developed for people with basic knowledge in software development. It can be either a programming course that was taken in the past or practical experience.

This course includes 90 academic hours delivered in 18 weekly meetings and 180 academic hours (and beyond) that take place at home. The training material (slides, video clips, assignments, solutions and code samples) for the entire course is organized on the e-learning platform we use during the course. Each meeting includes a theoretical lecture together with practical practice (at least 25% of each meeting). The practical practice includes coding by the instructor followed by the students and coding by the students with the assistance of the instructor. Each meeting is captured on video in order to allow the students effective learning process at home. Each meeting is broadcasted online in order to allow remote participation.

The course includes lots of relatively small assignments and a final project the students will develop as an open source project and place it on GitHub in order to allow other Kotlin developers to use it.

1

Introduction
What is Kotlin?
The Learning Curve
IDE
Android
Native
JavaScript

Basics
The package Statement

Defining Functions
Defining Local Variables
Comments
Strings Templates
The if Statement
Nullable Types
Type Checks
The for Loop
The while Loop
The when Expression
Ranges
Collections
Object Oriented
Coding Conventions

2

Coding Conventions *
Introduction
The Java Coding Conventions
The Colon Character
Lambda Expressions
Class Header Formatting
The Unit Type
Properties


Basic Types
Introduction
Numbers
Underneath Representation
Explicit Conversion
Operators
Floating Point numbers Conversion
Characters
Boolean
Arrays
Strings

Control Flow
Introduction
The if Expression
The when Expression
The for Loop
The while Loop


Packages
Introduction

The package Statement

The import Statement

The as Keyword

The import Statement

Top Level Declaration


Classes (Basic OOP)
The class Keyword

Constructors
Primary Constructor
Secondary Constructors
Default Constructor
Class Instantiation
Class Members

3

Classes (Inheritance)
The Any Class
The Base Class
The open Keyword
Overriding Methods
The final Keyword
Overriding Properties
The super Keyword
Overriding Rules
Abstract Classes
Companion Objects
Declaring Properties
Backing Properties
Compile Time Constants
Late Initialized Properties & Variables

4

Classes (Interfaces)
Interfaces
Interfaces Hierarchy
Interface Methods Implementation
Interfaces Conflicts


Classes (visibility)
Visibility Modifiers
Visibility Modifiers inside Packages
Visibility Modifiers inside Classes
Visibility Modifiers inside Modules


Classes (Data Classes)
Introduction to Data Classes
Code Samples
The copy Function


Classes (Sealed Classes)
Introduction to Sealed Classes
Sealed Classes Code Samples
Sealed Classes and The when Statement

5

Generics
Introduction

The our and in Modifiers
Generic Functions
Upper Bounds


Inner & Nested Classes
Introduction
Inner Class
Anonymous Inner Class
Nested Classes

6

Enum
Introduction
Simple Enum
Enum Constants are Objects
Anonymous Classes
Implementing Interfaces
The valueOf Functions
The values Function


Objects
Introduction
Object Expression
Object Inheritance
Plain Simple Object
Anonymous Object Type
Enclosing Scope Variables
Object Declaration
Companion Objects


Functions
Introduction
Defining Functions
Default Arguments
Named Arguments
Vararg Named Arguments
Unit Returning Functions
Single Expression Value
Explicit  Return Type
Variable Number of Arguments
The infix Notation
Top Level Functions
Local Functions
Member Functions
Generic Functions
Tail Recursive Function


Enum in Java @
http://www.abelski.com/courses/j2se_intro/oop.pdf 

7

Exceptions
Introduction
The throw Expression
The try Expression
Checked Exceptions
The Nothing Type


Extensions
Introduction
Extension Functions
Extension Properties
Companion Objects Extensions
Top Level Extensions
Extensions as Members


Nullable
Introduction
Using Nullable Types
The Safe Call Operator
The let Operator
The ?: Elvis Operator
The !! Operator
The as? Operator
Collections of Nullable Type Objects

8

Collections
Introduction
Creating Lists and Sets
List Code Sample
Set Code Sample
Creating Map
Map Code Sample
Covariant Types
Samples
The filter Extension Method
The none Extension Method

Ranges
Introduction
The downTo() Function
The step() Function
The until() Function

Destructuring
Introduction
Data Classes
Destructuring in for Loop
Returning Multiple Values
Unused Variables

9

Lambdas (part 1)
Higher Order Functions
Function Types
Parameters Names
Combining Function Types
Instantiate Function Type
Compiler Inference
Function Type with Receivers
Invoking Function Type Instances
Function Literals
Lambda Expressions Syntax

Lambdas (part 2)
The Function Last Parameter
The id Implicit Parameter
The Returned Function
LINQ Style Lambda Expressions
The Underscore Style
Introduction to Destructuring
Destructuring in Lambdas

10

Operators Overloading
Introduction
Unary Operators
Binary Operators
The in Operator
The indexed Access Operator
The invoke Operator
Augmented Assignment Operator
The Comparison Operators


Threads
Introduction
The fixRateTimer Function
The thread Function

Threads in Java @
http://www.abelski.com/courses/j2se_intro/threads.pdf 

Code Sample for wait and notify in Java @
https://javabook.co.il/wordpress/?p=114

11

Serialization
Introduction
The @Serializable Annotation

XML
Introduction
DOM Parser
Code Sample


additional slides about XML in Java @ http://lifemichael.com/moodle/course/view.php?id=236 

additional slides about DOM in Java @
http://lifemichael.com/moodle/course/view.php?id=222

JSON
Introduction
Klaxon Parser

Reflection
Introduction
Classes References
Properties References
Functions References
Callable References
Property References
Constructor References

12

I/O Streams
Introduction
The File Class
Extensions for File
The URL Class

Extensions for URL
The FileTreeWalk Class

additional slides about I/O in Java @
http://www.abelski.com/courses/j2se_intro/io.pdf
The OkIO Library *
TBA

Equality
Introduction
Structural Equality
Referential Equality


Idioms
Introduction
Data Classes
Function Parameters Default Values
Filtering List
Strings Interpolation
Instance Type Checking
Map Traversing
Range Traversing
Read Only List
Accessing Map
Lazy Property
Extension Methods
Singelton
If not Null Shorthand
Try & Catch Statement
Single Expression Functions
The with Statement

13

Using & Defining Annotations *      
Introduction
Jump Start
The @Target Annotation
The @Retention Annotation
The @Repeatable Annotation
The @MustBeDocumented Annotation
Code Samples

                   
Coding Conventions *
Introduction
The Java Coding Conventions
The Colon Character
Lambda Expressions
Class Header Formatting
The Unit Type
Properties

Unit Testing *
Introduction
JUnit 5
Samples


Inline Functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
Introduction
The inline Modifier
The noinline Modifier
Inline Properties


Dependency Injection *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
TBA
     
Delegation
Introduction
Code Samples
Overriding
Code Samples


Kotlin Modules *
TBA

Kotlin Obfuscation *
TBA

The ‘this’ Keyword  
Introduction
Using this inside Extension Function
Using this inside Inner Scope
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Networking
Introduction
The fuel Library
The Ktor Library

KDoc *
Introduction
KDoc Comments
Block Tags
Inline Markups
Module Documentation
Package Documentation

Calling Java from Kotlin
Calling Java from Kotlin
Getters and Setters
Methods Returning Void
Configuration
Mapped Types
Java Generics in Kotlin
Java Arrays
Java Varargs
Operators
Checked Exceptions
Objects Methods
Inheritance from Java Classes
Accessing Static Members
SAM Conversions
Using JNI
Calling Kotlin from Java
Properties
Package Level Functions
Instance Fields
Static Fields
Static Methods
Default Methods
Visibility
KClass
Signature Clashes
Overloads Generation
Checked Exceptions
Null Safety
Generics
The Nothing Type
                                                                                   

14

Coroutines (part 1)
What is Coroutine?
The kotlinx.couroutoin Library
Simple Coroutines
Coroutines as Light Weight Threads
The Global Scope
The
launch Function
The
delay Function
The
runBlocking Function
Structured Concurrency
The
coroutineScope Function
Structured Coroutines
The
suspend Modifier
Suspending Functions
Lightweight Threads
Global Coroutines as Daemon Threads

Coroutines (part 2) *
Cancelling The Coroutine Execution
The
join Method
Coroutines Cancellation
The finally Block
Coroutine Timeout
Composing Suspending Functions
The
async Function
Lazily Invocation of The
async Function
Async Style Functions
Structured Concurrency
Coroutines Context and Dispatchers
Unconfined Dispatchers
Debugging Coroutines & Threads
Moving from One Thread to Another
Getting The Job from Context
Coroutines Childs
Naming Our Coroutines
Context Elements Combining
Coroutine Scope
Asynchronous Flow
Chanels
Closing Channels
Exceptions Handling



  1. October 5th, 2020
    The Coroutines topic was expended. Many more sub-topics were added. As of this update, this topic takes two full meetings.
  2. October 5th, 2020
    The Modules topic was added. The subtopics of this topic will be added at a later stage (TBA).
  3. October 5th, 2020
    The Obfuscation topic was added. The subtopics of this topic will be added at a later stage (TBA).  
  4. October 5th, 2020
    The Dependency Injection topic was added. The subtopics of this topic will be added at a later stage (TBA).  
  5. October 5th, 2020
    The OkIO library was added. The subtopics of this topic will be added at a later stage (TBA).  
    https://square.github.io/okio/ 
  6. October 5th, 2020
    The Lambdas topic was expanded. It has two full meetings.
  7. January 24th, 2021
    The Serialization topic was added.
  8. June 9th, 2024
    The course becomes shorter—14 meetings instead of 18. Specific topics are marked with * (if time allows)