From the course: Build Spring Boot Apps with the Kotlin Programming Language

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Alternative class design

Alternative class design

- [Instructor] Now they're not, really doing anything that sensible. So I'm going to remove these. But I'd like to show you an alternative, for how we could have created this customer class. I'm not going to say that this alternative is better, but I'd like to go through it, because it will help us understand, exactly how all these different things, these fields of constructors, and edit blocks are really working. So let's create this as a second class, within the same file. And well call this alternative customer. (typing quickly) Now in this version the optional field, the address, I'm going to make that a field within the class, rather than part of the primary constructor. So we're going to have primary constructor, consisting of the name as a string, and the age as an integer. (typing quickly) And in fact I'll change that to a Var, so we're doing exactly the same thing. And then within the code for the class itself, is where I'm going to define the address. And I'm going to define…

Contents