Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Next Level DSLs

Next Level DSLs

Configure your app the Kotlin way!

Aaron will walk you through the design of a pluggable app architecture, all driven by an expansive domain-specific language executed at run-time.

Heavily inspired by the structure of build.gradle, this talk will demonstrate how you can push your configuration logic into a type-safe, declarative, and convenient format.

Source Code: https://gitlab.com/asarazan/kotlinconf18

Aaron Sarazan

October 04, 2018
Tweet

Other Decks in Programming

Transcript

  1. This is Really Unpleasant ...and there has to be a

    better way. • XML • Configuration • Declaration • Boilerplate • Builders
  2. Work Backwards Start from the result that you want to

    enable ...then write the code that enables it!
  3. Good Hygiene • Don’t pollute the global namespace • Unary

    “+” only if well-scoped • Keep Lambda files next to your builder classes ◦ Plugin.kt ◦ PluginLambdas.kt • Don’t extend system types ◦ String, Int, etc.
  4. Good Hygiene • Don’t pollute the global namespace • Unary

    “+” only if well-scoped • Keep Lambda files next to your builder classes ◦ Plugin.kt ◦ PluginLambdas.kt • Don’t extend system types ◦ String, Int, etc.
  5. Good Hygiene • Don’t pollute the global namespace • Unary

    “+” only if well-scoped • Keep Lambda files next to your builder classes ◦ Plugin.kt ◦ PluginLambdas.kt • Don’t extend system types ◦ String, Int, etc. • Have fun!