Visão Geral
Este Curso Kotlin, fornece habilidades sobre recursos orientados a objetos na linguagem de programação Kotlin e seu design e práticas.
Objetivo
Após concluir este Curso Kotlin, você será capaz de:
- Codifique aplicativos Kotlin usando estruturas, bibliotecas e ferramentas Java existentes.
- Escreva um aplicativo de back-end com código padrão mínimo.
- Compile o código Kotlin para bytecode JVM, JavaScript e Kotlin Native.
- Depure e otimize o código Kotlin.
- Teste e implante um aplicativo Kotlin.
Publico Alvo
- Esta classe Kotlin é adequada para desenvolvedores
Pre-Requisitos
- Experiência em programação Java.
Materiais
Inglês/Português/Lab Pratico
Conteúdo Programatico
Kotlin: What and Why?
- A taste of Kotlin
- Kotlin’s primary traits
- Target platforms: server-side, Android, anywhere Java runs
- Statically typed
- Functional and object-oriented
- Free and open source
- Kotlin applications
- Kotlin on Android
- The philosophy of Kotlin
- Pragmatic
- Concise
- Safe
- Interoperable
- Using the Kotlin tools
- Compiling Kotlin code
- Plug-in for IntelliJ IDEA and Android Studio
- Interactive shell
- Eclipse plug-in
- Online playground
- Java-to-Kotlin converter
Kotlin Basics
- Basic elements: functions and variables
- Hello, world!
- Functions
- Variables
- Easier string formatting: string templates
- Classes and properties
- Properties
- Custom accessors
- Kotlin source code layout: directories and packages
- Representing and handling choices: enums and “when”
- Declaring enum classes
- Using “when” to deal with enum classes
- Using “when” with arbitrary objects
- Using “when” without an argument
- Smart casts: combining type checks and casts
- Refactoring: replacing “if” with “when”
- Blocks as branches of “if” and “when”
- Iterating over things: “while” and “for” loops
- The “while” loop
- Iterating over numbers: ranges and progressions
- Iterating over maps
- Using “in” to check collection and range membership
- Exceptions in Kotlin
- “try”, “catch”, and “finally”
- “try” as an expression
Defining and Calling Functions
- Creating collections in Kotlin
- Making functions easier to call
- Named arguments
- Default parameter values
- Getting rid of static utility classes:
- Top-level functions and properties
- Extension Functions and Properties
- Extension functions and properties
- Imports and extension functions
- Calling extension functions from Java
- Utility functions as extensions
- No overriding for extension functions
- Extension properties
- Working with collections: varargs, infix calls, and library support
- Extending the Java Collections API
- Varargs: functions that accept an arbitrary number of arguments
- Working with pairs:
- Infix calls and destructuring declarations
- Working with strings and regular expressions
- Splitting strings
- Regular expressions and triple-quoted strings
- Multiline triple-quoted strings
- Making your code tidy: local functions and extensions
Classes, Objects, and Interfaces
- Defining class hierarchies
- Interfaces in Kotlin
- Open, final, and abstract modifiers: final by default
- Visibility modifiers: public by default
- Inner and nested classes: nested by default
- Sealed classes: defining restricted class hierarchies
- Declaring a class with nontrivial constructors or properties
- Initializing classes: primary constructor and initializer blocks
- Secondary constructors:
- Implementing properties declared in interfaces
- Accessing a backing field from a getter or setter
- Changing accessor visibility
- Compiler-generated methods: data classes and class delegation
- Universal object methods
- Data classes:
- Auto generated implementations of universal methods
- Class delegation: using the “by” keyword
- The “object” keyword:
- declaring a class and creating an instance, combined
- Object declarations: singletons made easy
- Companion objects:
- a place for factory methods and static members
- Companion objects as regular objects
- Object expressions: anonymous inner classes rephrased
Programming With Lambdas
- Lambda expressions and member references
- Introduction to lambdas: blocks of code as function parameters
- Lambdas and collections
- Syntax for lambda expressions
- Accessing variables in scope
- Member references
- Functional APIs for collections
- Essentials: filter and map
- “all”, “any”, “count”, and “find”:
- applying a predicate to a collection
- groupBy: converting a list to a map of groups
- flatMap and flatten: processing elements in nested collections
- Lazy collection operations: sequences
- Executing sequence operations:
- intermediate and terminal operations
- Creating sequences
- Using Java functional interfaces
- Passing a lambda as a parameter to a Java method
- SAM constructors:
- explicit conversion of lambdas to functional interfaces
- Lambdas with receivers: “with” and “apply”
- The “with” function
- The “apply” function
The Kotlin Type System
- Nullability
- Nullable types
- The meaning of types
- Safe call operator: “?.”
- Elvis operator: “?:”
- Safe casts: “as?”
- Not-null assertions: “!!”
- The “let” function
- Late-initialized properties
- Extensions for nullable types
- Nullability of type parameters
- Nullability and Java
- Primitive and other basic types
- Primitive types: Int, Boolean, and more
- Nullable primitive types: Int?, Boolean?, and more
- Number conversions
- “Any” and “Any?”: the root types
- The Unit type: Kotlin’s “void”
- The Nothing type: “This function never returns”
- Collections and arrays
- Nullability and collections
- Read-only and mutable collections
- Kotlin collections and Java
- Collections as platform types
- Arrays of objects and primitive types
Operator Overloading and Conventions
- Overloading arithmetic operators
- Overloading binary arithmetic operations
- Overloading compound assignment operators
- Overloading unary operators
- Overloading comparison operators
- Equality operators: “equals”
- Ordering operators: compareTo
- Conventions used for collections and ranges
- Accessing elements by index: “get” and “set”
- The “in” convention
- The “rangeTo” conventions
- The “iterator” convention for the “for” loop
- Destructuring declarations and component functions
- Destructuring declarations and loops
- Reusing property accessor logic: delegated properties
- Delegated properties: the basics
- Using delegated properties: lazy initialization and “by lazy()”
- Implementing delegated properties
- Delegated-property translation rules
- Storing property values in a map
- Delegated properties in frameworks
Higher-Order Functions
- Declaring higher-order functions
- Function types
- Calling functions passed as arguments
- Using function types from Java
- Default and null values for parameters with function types
- Returning functions from functions
- Removing duplication through lambdas
- Inline functions: removing the overhead of lambdas
- How inlining works
- Restrictions on inline functions
- Inlining collection operations
- Deciding when to declare functions as inline
- Using inlined lambdas for resource management
- Control flow in higher-order functions
- Return statements in lambdas: return from an enclosing function
- Returning from lambdas: return with a label
- Anonymous functions: local returns by default
Generics
- Generic type parameters
- Generic functions and properties
- Declaring generic classes
- Type parameter constraints
- Making type parameters non-null
- Generics at runtime: erased and reified type parameters
- Generics at runtime: type checks and casts
- Declaring functions with reified type parameters
- Replacing class references with reified type parameters
- Restrictions on reified type parameters
- Variance: generics and subtyping
- Why variance exists: passing an argument to a function
- Classes, types, and subtypes
- Covariance: preserved subtyping relation
- Contravariance: reversed subtyping relation
- Use-site variance: specifying variance for type occurrences
- Star projection: using * instead of a type argument
Annotations and Reflection
- Declaring and applying annotations
- Applying annotations
- Annotation targets
- Using annotations to customise JSON serialisation
- Declaring annotations
- Meta-annotations: controlling how an annotation is processed
- Classes as annotation parameters
- Generic classes as annotation parameters
- Reflection: Introspecting Kotlin objects at runtime
- The Kotlin reflection API:
- KClass, KCallable, KFunction, and KProperty
- Implementing object serialization using reflection
- Customizing serialization with annotations
- JSON parsing and object deserialization
- Final deserialization step:
- callBy() and creating objects using reflection
Coroutines in Kotlin
- Coroutines
- Coroutines Basics
- Cancellation and Timeouts
- Blocking vs Suspending
- Composing Suspending Functions
- Coroutine Context and Dispatchers
- Asynchronous Flow
- Channels
- Exception Handling and Supervision
- Shared Mutable State and Concurrency
- Standard APIs
- Low Level API: kotlin.coroutines
- Generators API in kotlin.coroutines
- Other High Level APIs in kotlin.coroutines
TENHO INTERESSE