Java to Kotlin:A Refactoring Guidebook
by: Duncan McGregor and Nat Pryce
Publisher Finelybook 出版社：O'Reilly Media; 1st edition (September 7,2021)
pages 页数：424 pages
It takes a week to travel the 8,000 miles overland from Java to Kotlin. If you’re an experienced Java developer who has tried the Kotlin language,you were probably productive in about the same time.
You’ll have found that they do things differently in Kotlin,though. Nullability is important,collections are different,and classes are final by: default. Kotlin is more functional,but what does that mean,and how should it change the way that you program? And what about all that Java code that you still have to support?
Your tour guides Duncan and Nat first made the trip in 2015,and they’ve since helped many teams and individuals follow in their footsteps. Travel with them as they break the route down into legs like Optional to Nullable,Beans to Values,and Open to Sealed Classes. Each explains a key concept and then shows how to refactor production Java to idiomatic Kotlin,gradually and safely,while maintaining interoperability.
The resulting code is simpler,more expressive,and easier to change. By the end of the journey,you’ll be confident in refactoring Java to Kotlin,writing Kotlin from scratch,and managing a mixed language codebase as it evolves over time.
Table of Contents
Chapter 1. Introduction
Chapter 2. Java to Kotlin Projects
Chapter 3. Java to Kotlin Classes
Chapter 4. Optional to Nullable
Chapter 5. Beans to Values
Chapter 6. Java to Kotlin Collections
Chapter 7. Actions to Calculations
Chapter 8. Static Methods to Top-Level Functions
Chapter 9. Multi- to Single-Expression Functions
Chapter 10. Functions to Extension Functions
Chapter 11. Methods to Properties
Chapter 12. Functions to Operators
Chapter 13. Streams to lterables to Sequences
Chapter 14. Accumulating Objects to Transformations
Chapter 15. Encapsulated Collections to Type Aliases
Chapter 16. Interfaces to Functions
Chapter 17. Mocks to Maps
Chapter 18. Open to Sealed Classes
Chapter 19. Throwing to Returning
Chapter 20. Performing I/O to Passing Data
Chapter 21. Exceptions to Values
Chapter 22. Classes to Functions
Chapter 23. Continuing the Journey
About the Authors