万本电子书0元读

万本电子书0元读

顶部广告

Programming Kotlin电子书

售       价:¥

19人正在读 | 0人评论 6.2

作       者:Stephen Samuel

出  版  社:Packt Publishing

出版时间:2017-01-01

字       数:179.2万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Familiarize yourself with all of Kotlin’s features with this in-depth guide About This Book Get a thorough introduction to Kotlin Learn to use Java code alongside Kotlin without any hiccups Get a complete overview of null safety, Generics, and many more interesting features Who This Book Is For The book is for existing Java developers who want to learn more about an alternative JVM language. If you want to see what Kotlin has to offer, this book is ideal for you. What You Will Learn Use new features to write structured and readable object-oriented code Find out how to use lambdas and higher order functions to write clean, reusable, and simple code Write unit tests and integrate Kotlin tests with Java code in a transitioning code base Write real-world production code in Kotlin in the style of microservices Leverage Kotlin’s extensions to the Java collections library Use destructuring expressions and find out how to write your own Write code that avoids null pointer errors and see how Java-nullable code can integrate with features in a Kotlin codebase Discover how to write functions in Kotlin, see the new features available, and extend existing libraries Learn to write an algebraic data types and figure out when they should be used In Detail Kotlin has been making waves ever since it was open sourced by JetBrains in 2011; it has been praised by developers across the world and is already being adopted by companies. This book provides a detailed introduction to Kotlin that shows you all its features and will enable you to write Kotlin code to production. We start with the basics: get you familiar with running Kotlin code, setting up, tools, and instructions that you can use to write basic programs. Next, we cover object oriented code: functions, lambdas, and properties – all while using Kotlin’s new features. Then, we move on to null safety aspects and type parameterization. We show you how to destructure expressions and even write your own. We also take you through important topics like testing, concurrency, microservices, and a whole lot more. By the end of this book you will be able to compose different services and build your own applications. Style and approach An easy to follow guide that covers the full set of features in Kotlin programming.
目录展开

Programming Kotlin

Programming Kotlin

Credits

About the Authors

About the Reviewers

www.PacktPub.com

Why subscribe?

Customer Feedback

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. Getting Started with Kotlin

Using the command line to compile and run Kotlin code

Kotlin runtime

The REPL

Kotlin for scripting

Kotlin with Gradle

Kotlin with Maven

IntelliJ and Kotlin

Eclipse and Kotlin

Mixing Kotlin and Java in a project

Summary

2. Kotlin Basics

Vals and vars

Type inference

Basic types

Numbers

Booleans

Chars

Strings

Arrays

Comments

Packages

Imports

Wildcard imports

Import renaming

String templates

Ranges

Loops

Exception handling

Instantiating classes

Referential equality and structural equality

This expression

Scope

Visibility modifiers

Private

Protected

Internal

Control flow as expressions

Null syntax

Smart casts

Explicit casting

When expression

When (value)

When without argument

Function Return

Type hierarchy

Summary

3. Object-Oriented Programming in Kotlin

Classes

Access levels

Nested classes

Data classes

Enum classes

Static methods and companion objects

Interfaces

Inheritance

Visibility modifiers

Abstract classes

Interface or abstract class

Polymorphism

Overriding rules

Inheritance versus composition

Class delegation

Sealed classes

Summary

4. Functions in Kotlin

Defining functions

Single expression functions

Member functions

Local functions

Top-level functions

Named parameters

Default parameters

Extension functions

Extension function precedence

Extension functions on nulls

Member extension functions

Overriding member extension functions

Companion object extensions

Multiple return values

Infix functions

Operators

Operator overloading

Basic operators

In/contains

Get/set

Invoke

Comparison

Assignment

Java interop

Function literals

Tail recursive functions

Varargs

Spread operator

Standard library functions

Apply

Let

With

Run

Lazy

Use

Repeat

Require/assert/check

Generic functions

Pure functions

Java from Kotlin

Getters and setters

Single abstract methods

Escaping Kotlin identifiers

Java void methods

Kotlin from Java

Top-level functions

Default parameters

Object and static methods

Erasure naming

Checked exceptions

Summary

5. Higher Order Functions and Functional Programming

Higher order functions

Returning a function

Function assignment

Closures

Anonymous functions

Function references

Top-level function references

Member and extension function references

Bound references

Function-literal receivers

Functions in the JVM

Bytecode

Function composition

Inline functions

Noinline

Currying and partial application

Currying in action

Adding currying support

Memoization

Implementing memoization

Type alias

Either

Fold

Projection

Further projection functions

Custom DSLs

Infix functions as keywords

Using function receivers in a DSL

Validation and error accumulation

Summary

6. Properties

Why use properties?

Syntax and variations

Visibility

Late initialization

Delegated properties

Lazy initializations

Lateinit versus lazy

Observables

A non-null property delegate

Properties or methods?

Summary

7. Null Safety, Reflection, and Annotations

Nullable types

Smart cast

Safe null access

Force operator

Elvis operator

Safe casting

Optionals

Creating and returning an Optional

Using an Optional

Reflection

KClass

Instantiation using reflection

Constructors

Instantiation with callBy

Objects and companions

Useful KClass properties

Reflective functions and properties

Invoking a function reflectively

Declared and undeclared

Annotations

Annotation parameters

Standard annotations

@JvmName

@JvmStatic

@Throws

@JvmOverloads

Runtime annotation discovery

Summary

8. Generics

Parameterised functions

Parameterized types

Bounded polymorphism

Upper bounds

Multiple bounds

Type variance

Invariance

Covariance

Covariant return

Contravariance

Variance overview

Nothing type

Type projection

Type erasure

Type reification

Recursive type bounds

Algebraic data types

Summary

9. Data Classes

Automatic creation of getters and setters

The copy method

toString out of the box

hashCode and equals methods generated for you

Destructed declarations

Destructing types

Data class definition rules

Limitations

Summary

10. Collections

Class hierarchy

Arrays

Lists

Maps

Sets

Read-only views

Indexed access

Sequences

Summary

11. Testing in Kotlin

Getting started

Choosing a spec

Matchers

String matchers

Collection matchers

Floating point matchers

Expecting exceptions

Combining matchers

Custom matchers

Inspectors

Interceptors

The test case interceptor

The spec interceptor

Project config

Property testing

Specifying a generator

A custom generator

Table-driven testing

Testing non-deterministic code

Tags, conditions, and config

Config

Conditions

Tags

One instance

Resources

Summary

12. Microservices with Kotlin

Definition

Drawbacks

Why microservices?

Lagom

Defining services

Implementing a Lagom service

Summary

13. Concurrency

Threads

Blocking

Creating a thread

Stopping a thread

Thread interrupts

CPU-bound versus I/O-bound

Deadlocks and livelocks

Executors

Race conditions

Monitors

Locks

Read-write locks

Semaphores

The bounded buffer problem

Concurrent collections

ConcurrentHashMap

A blocking queue

Atomic variables

CountDownLatch

Cyclic Barrier

Non-blocking I/O and asynchronous programming

Futures

Summary

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部