Slide 1

Slide 1 text

Creating Kotlin DSLs on Android

Slide 2

Slide 2 text

#BADGkotlinDSL But first, what is a DSL? A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains.

Slide 3

Slide 3 text

#BADGkotlinDSL Some popular DSL examples

Slide 4

Slide 4 text

#BADGkotlinDSL Some Android DSL examples

Slide 5

Slide 5 text

#BADGkotlinDSL Some Android DSL examples

Slide 6

Slide 6 text

#BADGkotlinDSL Let’s create our DSL

Slide 7

Slide 7 text

#BADGkotlinDSL From old to new: Old declarative style I

Slide 8

Slide 8 text

#BADGkotlinDSL From old to new: Old declarative style II

Slide 9

Slide 9 text

#BADGkotlinDSL From old to new: New DSL style

Slide 10

Slide 10 text

#BADGkotlinDSL How to: Overview

Slide 11

Slide 11 text

#BADGkotlinDSL How to: Start creating a builder

Slide 12

Slide 12 text

#BADGkotlinDSL How to: The build() function, title

Slide 13

Slide 13 text

#BADGkotlinDSL How to: The build() function, add menu

Slide 14

Slide 14 text

#BADGkotlinDSL How to: The build() function, back action

Slide 15

Slide 15 text

#BADGkotlinDSL How to: The build() function, add items

Slide 16

Slide 16 text

#BADGkotlinDSL How to: Adding items, item setup

Slide 17

Slide 17 text

#BADGkotlinDSL How to: Adding items, add to items to list

Slide 18

Slide 18 text

#BADGkotlinDSL How to: Item builder

Slide 19

Slide 19 text

#BADGkotlinDSL How to: Adding back action, back setup

Slide 20

Slide 20 text

#BADGkotlinDSL How to: Back builder

Slide 21

Slide 21 text

#BADGkotlinDSL How to: Final step, Ext.func. for Toolbar

Slide 22

Slide 22 text

#BADGkotlinDSL Putting all together https://github.com/FireZenk/ComicWorld/blob/develop/app/src/main/java/or g/firezenk/comicworld/ui/extensions/ToolbarDSL.kt

Slide 23

Slide 23 text

#BADGkotlinDSL And here it is the our Toolbar built using our brand new DSL notation

Slide 24

Slide 24 text

#BADGkotlinDSL Questions?

Slide 25

Slide 25 text

#BADGkotlinDSL Thanks! and special thanks to Bernat Borrás and Carlos Carrasco who collaborated in the creation of some of the DSLs shown Useful resources: - Sample repo for this talk https://github.com/FireZenk/ComicWorld - Anko https://github.com/Kotlin/anko - kotlinx.html https://github.com/Kotlin/kotlinx.html - Village DSL https://github.com/zsmb13/VillageDSL - Want more? https://kotlin.link @firezenk