Kotlin For Beginners: References, Immutability (Const and Val), Properties, Variables, Data Classes (Skillshare)

Offered by Skillshare,
Kotlin For Beginners: References, Immutability (Const and Val), Properties, Variables, Data Classes (Skillshare)

In this short class, you will learn the fundamentals of how to represent information virtually in a Kotlin program. About half of what we do as programmers is design data structures to represent real world information virtually, and it turns out that there are good and bad ways to do this! One of the most important takeaways of this class, is that it is critically important to separate things which change (mutable) from things which don't change (immutable).

Topics include:

  • How references work with the JVM (simplified for beginners)
  • The problem of Shared Mutable State (this is bad)
  • How to avoid Shared Mutable State by introducing Immutability (const val and val properties) to your code
  • How and when it makes sense to use var references
  • How to make classes, and the data class construct

As discussed in this class, one of the most difficult technical challenges which programmers face, is dealing with Shared Mutable State (Shared change-able data). Our first defense against such problems, is to work with Immutable Data as often as possible.
Using either the try.kotlinlang.org online IDE, or your own preferred IDE, write a simple program which has:

  • A data class of some kind with at least two val properties, such as a "User" data class
  • A main function which serves as the entry point of the program's execution

Instructions:

  1. Create a val reference of the same type as your data class (i.e. instantiate your data class)
  2. Create a second val reference from the first val reference, using the copy() function (this function comes from the data class keyword).
  3. Change at least one of the properties in this new val reference, by using default arguments within the copy() function.

The purpose of this small project is to get you used to working with immutable data and vals. At first it can appear impossible to make a working program using data classes with only val references, but by using the copy function, we can create new immutable copies based on old data, mutating only the properties we wish to!

Go to Class
MOOC List is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Related Courses

Javascript Fun: Build a Tip Calculator! (Skillshare) Skillshare
Skillshare

Javascript Fun: Build a Tip Calculator! (Skillshare)

Welcome to the Javascript fun series! For web design or development, there are 3 must-know technologies, HTML, CSS, and Javascript. The main aim of the Javascript fun series is to take your knowledge of these 3 (only a little is required!), and put them into practice by building a series of educational, yet fun projects that show you exactly how they work perfectly together. Working on projects and solving problems is a great way to learn

Self Paced
Self-Paced
Twitter API JavaScript Node Exercise (Skillshare) Skillshare
Skillshare

Twitter API JavaScript Node Exercise (Skillshare)

Twitter API JavaScript Node Exercise. Explore the Twitter Developer API connect from your local machine. Use AJAX JavaScript and Node to setup twitter search. Perfect course for beginners to explore the MASSIVE twitter API. This course will teach you how to setup a local server, connect the Twitter API and return data to output into your web page. Its amazing how much information is available on Twitter, connecting the API is easy and can provide real world working experience with JSON AJAX and APIs.

Self Paced
Self-Paced
Javascript Fun: Build a Number Match Game! (Skillshare) Skillshare
Skillshare

Javascript Fun: Build a Number Match Game! (Skillshare)

Welcome to the Javascript fun series! For web design or development, there are 3 must-know technologies, HTML, CSS, and Javascript. The main aim of the Javascript fun series is to take your knowledge of these 3 (only a little is required!), and put them into practice by building a series of educational, yet fun projects that show you exactly how they work perfectly together. Working on projects and solving problems is a great way to learn.

Self Paced
Self-Paced
Introduction to PHP (Skillshare) Skillshare
Skillshare

Introduction to PHP (Skillshare)

In this course, You will learn about What is PHP and How it Works? Right after this course, you will be able to explain concepts like Client Server Model, Request Response Pattern and Describe about PHP Language in your own words. This is the second course topic that you should take which helps you to understand the basic concepts Why PHP was developed and What problem PHP language solves. This course is a Introduction to PHP and will introduce you to Core Web Concepts and PHP.

Self Paced
Self-Paced
How To Make A Wordpress Website - Elementor Tutorial (Skillshare) Skillshare
Skillshare

How To Make A Wordpress Website - Elementor Tutorial (Skillshare)

Come learn how to make a wordpress website in 1 hour! I will show you step by step to easily create your wordpress website in a few clicks! Lets Get Started! Its simple, gets your domain for your wordpress website. Install Wordpress. Install Your Wordpress Theme. Than simply install a plugin that will give you access to more than 1700+ elementor templates for free!

Self Paced
Self-Paced
Data Structures and Algorithms in Python (Skillshare) Skillshare
Skillshare

Data Structures and Algorithms in Python (Skillshare)

This course will help you in better understanding of the basics of Data Structures and how algorithms are implemented in the high level programming language. This course consists of lectures on data structures and algorithms which covers the computer science theory + implementation of data structures in python language. This course will also help students to face interviews at the top technology companies. This course is like having personal tutors to teach you about data structures and algorithms.

Self Paced
Self-Paced
ES6 JavaScript Classes the Easy Way (Skillshare) Skillshare
Skillshare

ES6 JavaScript Classes the Easy Way (Skillshare)

In 2015, the JavaScript programming language got a major facelift with many improvements to the syntax and tons of new features. This new version is known as ES6, or ES2015, and each year since an updated version has been released. ES6 Classes, as well as instance and static methods, are vitally important to know and understand because so many projects and companies are migrating to the newest version of JavaScript. Many Front End libraries, such as React, rely heavily on the new Class syntax.

Self Paced
Self-Paced
How To Make A WordPress Blog For Beginners Step By Step (Skillshare) Skillshare
Skillshare

How To Make A WordPress Blog For Beginners Step By Step (Skillshare)

Hi, in this class I’m going to show you how to start blogging and create a beautiful blog which is perfect for 2018 and beyond! I’ve been making websites and blogs and also teaching how to properly set them up for years now and I get bombarded with questions on a daily basis like…How do I start a blog? What’s the easiest way to get started without overwhelm? Which platform should I use?

Self Paced
Self-Paced
How to Create a Personal/Portfolio Website (Skillshare) Skillshare
Skillshare

How to Create a Personal/Portfolio Website (Skillshare)

This class will teach you how to professionally create an awesome personal/portfolio website! By the end of the class,you'll have a beautiful and fully functioning website that can help you land jobs, clients, and mega style points with employers. This class is taught step-by-step so it's very easy to follow along with your own website. I also include a free template of the website we will we making (in the Projects Tab > Resources), as well as follow along images for you.

Self Paced
Self-Paced