官术网_书友最值得收藏!

Kotlin – Data Types, Objects, and Classes

In this chapter, we'll cover Kotlin's type system, object-oriented programming (OOP) with Kotlin, modifiers, destructuring declarations, and more.

Kotlin is, primarily, an OOP language with some functional features. When we use OOP languages to resolve problems, we try to model the objects that are a part of our problem in an abstract way with the information that is relevant to the problem.

If we're designing an HR module for our company, we'll model employees with state or data (name, date of birth, social security number, and others) and behavior (pay salary, transfer to another division, and others). Because a person can be very complex, there is information that isn't relevant for our problem or domain. For example, the employee's favorite style of bicycle isn't relevant for our HR system, but it is very relevant for an online cycling shop.

Once we identify the objects (with data and behavior) and the relationship with other objects of our domain, we can start developing and writing the code that we'll make a part of our software solution. We'll use language constructs (construct is a fancy way to say allowed syntax) to write the objects, categories, relationships, and so on.

Kotlin has many constructs that we can use to write our programs and, in this chapter, we'll cover many of those constructs, such as:

  • Classes
  • Inheritance
  • Abstract classes
  • Interfaces
  • Objects
  • Generics
  • Type alias
  • Null types
  • Kotlin's type system
  • Other types
主站蜘蛛池模板: 宜阳县| 东乌| 云阳县| 汝州市| 弋阳县| 沁阳市| 乐至县| 鸡西市| 贡觉县| 化德县| 嵊州市| 揭东县| 锡林浩特市| 瑞丽市| 天峨县| 称多县| 白朗县| 洛扎县| 翼城县| 宜章县| 洛宁县| 岳普湖县| 响水县| 栾城县| 嵩明县| 正镶白旗| 宽甸| 连云港市| 汶川县| 海淀区| 贵州省| 甘南县| 左贡县| 海晏县| 包头市| 新蔡县| 平江县| 宜宾市| 林芝县| 喜德县| 余庆县|