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

9

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


Lambdas
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
The Function Last Parameter
The id Implicit Parameter
The Returned Function
LINQ Style Lambda Expressions
The Underscore Style

10

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

11

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

12

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

13

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

14

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

15

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


Working on Final Project
                                                                                         

16

Delegation
Introduction
Code Samples
Overriding
Code Samples

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


Working on Final Project

17

Java Interop
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


Coroutines

Working on Final Project

18

Coroutines
Java Interop

Final Project Presentation