Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Object-Oriented Programming with Kotlin

You're reading from   Hands-On Object-Oriented Programming with Kotlin Build robust software with reusable code using OOP principles and design patterns in Kotlin

Arrow left icon
Product type Paperback
Published in Oct 2018
Publisher Packt
ISBN-13 9781789617726
Length 370 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Abid Khan Abid Khan
Author Profile Icon Abid Khan
Abid Khan
Igor Kucherenko Igor Kucherenko
Author Profile Icon Igor Kucherenko
Igor Kucherenko
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Getting Started with Kotlin FREE CHAPTER 2. Introduction to Object-Oriented Programming 3. The Four Pillars of Object-Oriented Programming 4. Classes - Advanced Concepts 5. Data Collection, Iterators, and Filters 6. Object-Oriented Patterns in Kotlin 7. Coroutines - a Lightweight Thread? 8. Interoperability 9. Regular Expression and Serialization in Kotlin 10. Exception Handling 11. Testing in Object-Oriented Programming with Kotlin 12. Assessments 13. Other Books You May Enjoy

What this book covers

Chapter 1, Getting Started with Kotlin, provides a brief overview of the Kotlin programming language. This chapter also covers data types and how null safety and type casting works. It also provides an introduction to operators and flow controls. At the end of this chapter, we will look at loops and functions.

Chapter 2, Introduction to Object-Oriented Programming, discusses what object-oriented programming is and why it is different and better than procedural programming. This chapter explains classes and data classes in Kotlin, and how Kotlin makes them unique. It also discusses in detail constructors, types of constructors, and properties, and what is meant by properties as first class citizens.

Chapter 3, The Four Pillars of Object-Oriented Programming, provides a thorough description of four pillars of object-oriented programming. It also explains what encapsulation is and how inheritance works. We also look into topics such as why choose polymorphism and what the benefits of abstraction are. Finally, we will learn how to declare a parent class and how to utilize resources in child class. In addition to defining derived classes, this chapter discusses how variables and functions can be redefined in child class, explicit type casting, and implicit type conversion within class hierarchies.

Chapter 4, Classes – Advanced Concepts, describes the key concepts of programming that are provided exclusively by Kotlin. This chapter discusses the concepts of sealed classes, object and companion objects, and why they are different from traditional classes. It also explains properties and delegates in classes.

Chapter 5, Data Collection, Iterators, and Filters, describes the handling of data collection by using different data structures provided in Kotlin. We also learn how to define and use arrays and how to utilize different templates for the efficient management of object collections such as lists, sets, collections, and maps. Besides discussing different data collection techniques, this chapter explains the power of interfaces used in collection classes. You will learn what an iterator is, how iterators are used with different collections, and the issues you may encounter while using it. This chapter also explains what filters are, how filters work, and how to ignore irrelevant data. At the end, this chapter elaborates on how to write your own filters.

Chapter 6, Object-Oriented Patterns in Kotlin, deals with the advanced concepts of object-oriented programming referred to as design patterns. Design patterns are a general solution to a known problem in software design. Design patterns can speed up development processes and reduce the risk of design errors that may occur at a later stage. Different design patterns are used for different problems; this chapter discusses software design challenges and design patterns. Each design pattern is subdivided into different categories that will be discussed in further detail.

Chapter 7, Coroutine – a Lightweight Thread?, describes how Kotlin has introduced a new library called coroutine. Coroutines can be considered a lightweight thread that do not push CPU to its limits, even when thousands of requests are in progress. This chapter explains what a coroutine is, and why it is superior to traditional threads in Java.

Chapter 8, Interoperability, discusses the fact that Kotlin is a superset of Java that is designed with Java interoperability in mind. Interoperability means you can call Java functions in Kotlin, and vice versa, and you can have both Java and Kotlin files in the same application. This chapter discusses in detail the technology behind interoperability and how to write cross-platform code. Most importantly, it also explains how to handle nullable calls that may appear from Java.

Chapter 9, Regular Expression and Serialization in Kotlin, describes how regular expressions, also known as regex, are a combination of different characters that helps to find and locate the necessary information from a huge amount of text. This technique is also called pattern matching, where users provide a string (pattern) and get a list of exact or similar matches. All advanced text editors use regular expressions to find the variable in your code. In this chapter, you will see that Kotlin has provided complete support for regular expressions and how they support writing bug-free patterns. This chapter also discusses serialization and how Kotlin works with text formats such as JSON.

Chapter 10, Exception Handling, discusses exceptions and exception handling in detail. We also learn about what the different keywords are try, catch, throw finally, and more, the different types of exceptions, and how a user can create user-defined exceptions and handle them. This chapter also explains how to prepare test environments to be able to write some tests.

Chapter 11, Testing in Object-Oriented Programming with Kotlin, provides an insight into the importance of testing, why testing is required, and the repercussions if code is released without testing. This chapter also explains the testing techniques, the dedicated Kotlin library for testing, and how Kotlin can help to write clean and readable test cases.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image