Object Oriented Programming with Kotlin 1
by Kevin Jones
The Kotlin designers took the experience of Java and used it to make Kotlin a better OO language. For example, classes are 'public' and 'final' by default. This course shows you how to use such Kotlin features to create better objected oriented code.
What you'll learn
Kotlin is a more modern version of Java. Being Java like, Kotlin has a strong Object Oriented foundation and builds on that foundation to offer features that are not found in Java. In this course, Object Oriented Programming with Kotlin 1, you will learn how to exploit those features to build object oriented applications. First, you will cover the basics such as defining classes in Kotlin, abstract base classes and interfaces. You will look at class derivation and the fact that Kotlin classes are ‘closed’ by default. Next, you will explore Kotlin’s construction mechanism and the fact that In Kotlin, classes have a single ‘primary’ constructor but can also have ‘secondary’ constructors, although you will see why these are not often necessary. You will also look at what you can do if a class requires more complex construction. Finally, you will discover how Kotlin supports ‘Nested’ and ‘Inner’ classes and also anonymous inner classes and see why these are important and where they might be used. Kotlin also provides ‘Data Classes’ that are used as ‘DTOs’, they provide automatic support for ‘hashCode’ and ‘equals’ methods so make them easy to use in containers such as collections. Kotlin does not have the concept of ‘static’ methods, but instead has ‘companion’ objects, these are Singletons and you will see where and how to use these in your code. Kotlin classes can also be generic. You will be introduced to the idea of generic types and be shown how they are used in your code. By the end of this course, you will be able to write small snippets of sample code to demonstrate the topics covered, and also have the knowledge required to write a complete application, bringing together the material to show how to apply object oriented techniques in practice.
About the author
A long time ago in a university far, far away Kevin fell in love with programming. Initially on the university's DEC20 computer doing BASIC and Pascal and a little bit of Fortran. His first job had him writing batch PL/1 on an IBM mainframe where he also discovered the arcane delights of JCL. He soon realized the multiuser systems were not for him after discovering the delights of dBase IV on IBM PCs. From here it was all downhill as he became addicted to C and the Windows API. Just missing out ... moreon coding for Windows 1, he did code for the other 16 bit versions of Windows, 2 and 3, including the various network-ready versions. He still remembers the awkwardness of having to carry an IBM Token Ring MAU with him wherever he went.
After trying to pretend that Windows and C were really object oriented he decided that it would be better to learn C++. It was around this point that he realized that as well as writing code for a living he could be paid for telling people how to write code for a living. He taught Windows, MFC and C++ for a UK training company before his spirit was broken on the back of the OLE support in MFC when he finally stepped away from the nightmare of unmanaged code to the nirvana of the managed runtime called Java.
It was at this time that he spoke at several JavaOne conferences usually on the subject of Servlets, JavaServer Pages and tag libraries. After buying the Sun employees copious amounts of Apple Martini Kevin was invited onto the expert groups for the Servlet and JSP specifications.
Oh, how he laughed when .Net appeared and the same arguments raged about non-deterministic destruction and garbage collection that were now so old hat in the Java world. He finally got his hands dirty in C# and .Net about eight years ago, again working in the web tier and hating every minute of the using the monstrosity that was and is ASP.Net Web Forms. It wasn't until MVC appeared that he finally felt he had come home to Microsoft.
Now of course MVC is so last year and Kevin is focusing more and more on rich clients using JavaScript and tools such as Knockout and AngularJS. He believes that JavaScript is the best thing since, well, JavaScript.
He still retains his passion for developing and teaching; spending about a quarter of the year doing the latter and most of the time doing the former.
When not stuck in front of a computer you can find him: with his nose in a book, a good one preferably, but almost any book would do; watching a film; walking; running; or annoying his wife by watching sports on television.