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

Talking to Strangers: An Introduction to User Interviews (Skillshare) Skillshare
Skillshare

Talking to Strangers: An Introduction to User Interviews (Skillshare)

Design is nothing without the user, and the best way to find out what the user wants is to talk to them face-to-face. In this class, we will cover everything you need to get started with conducting user interviews to collect valuable qualitative data that will help you humanize your designs. You’ll learn how to write a script...and how/when to veer off the script. You’ll learn how to listen to the user’s stories, and how to respond on the fly to a constantly adapting conversation.

Self Paced
Self-Paced
How To Make A Real Estate Website With Wordpress 2017 (Skillshare) Skillshare
Skillshare

How To Make A Real Estate Website With Wordpress 2017 (Skillshare)

n this video, I will teach you how to make a fully responsive real estate wordpress website. This wordpress tutorial will help real estate agents, realtors, or property managers create a fully functional real estate wordpress website. The theme i use in this tutorial is the agentpress pro theme created by studiopress. Trust me, i spent about 1 month researching real estate wordpress themes and this was by far the best real estate websites. The theme is very easy to use and very responsive on the mobile devices.

Self Paced
Self-Paced
How To Make A Wordpress Website -- Complete Beginners Guide (Skillshare) Skillshare
Skillshare

How To Make A Wordpress Website -- Complete Beginners Guide (Skillshare)

Want To Learn How To Make A Website With Wordpress? In this tutorial, I go step by step to show you how to build a wordpress website step by step! After you watch this video, you will be able to create a website from scratch with no experience. I use elementor and the oceanwp wordpress theme in this tutorial!

Self Paced
Self-Paced
Web Design Essentials: Creating Marketing Homepages That Drive Results  (Skillshare) Skillshare
Skillshare

Web Design Essentials: Creating Marketing Homepages That Drive Results (Skillshare)

Design websites that drive results! In this 60-minute class, join Dennis Field — a designer and product evangelist for web prototyping leader InVision — as he shares how to refine your creative process, capitalize on feedback, and use best practices to design a marketing site that leads to conversions for your company. This class is perfect for freelance website and product designers, small web design teams, and everyone who wants to increase the effectiveness of their web design.

Self Paced
Self-Paced
Typescript Design Patterns (Object-oriented programming) (Skillshare) Skillshare
Skillshare

Typescript Design Patterns (Object-oriented programming) (Skillshare)

Object oriented design patterns help you create more robust and flexible software. In this course I will show you how to use these patterns in TypeScript. Design patterns are best practices that will help you solve common problems in programming. There is no need to solve a generic problem that has been solved many times before. Simple example: how do you write a system that allows user to order a product and customize some of its features?

Self Paced
Self-Paced
Writing Code Faster with Emmet (Skillshare) Skillshare
Skillshare

Writing Code Faster with Emmet (Skillshare)

I LOVE finding ways to speed up or automate my work. So I'm very excited to introduce you to Emmet, a plugin that enables you to write code FASTER. What you will need: Emmet is available in most web editors. Adobe Dreamweaver, Brackets, Sublime Text etc. For this class, I'll be demonstrating Emmet using an online web editor I use on a daily basis - Codepen.

Self Paced
Self-Paced
Build Your Online Portfolio Without Writing Code (Skillshare) Skillshare
Skillshare

Build Your Online Portfolio Without Writing Code (Skillshare)

With the web becoming more and more involved in our daily lives, being able to create your own little corner of the web has never been more important (or exciting). In under one hour with Webflow's Mat Vogels, you'll cover a variety of different topics, including: Why you should be online in the first place; Basic web concepts, like the box model and responsive design; Building a website from scratch; Publishing a website.

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
Javascript Fun: Build a Photo Effects App! (Skillshare) Skillshare
Skillshare

Javascript Fun: Build a Photo Effects App! (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
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