Recent Posts
Archives

Posts Tagged ‘TornadoFX’

PostHeaderIcon [KotlinConf2019] Desktop Development with TornadoFX: Kotlinizing JavaFX with Liz Keogh

JavaFX, the successor to Swing for creating rich client applications in Java, offers a modern approach to desktop UI development with a cleaner separation of function and style. However, working directly with JavaFX can sometimes involve verbosity and untyped stylesheets. Liz Keogh, a renowned Lean and Agile consultant and a core member of the BDD community, presented a compelling alternative at KotlinConf 2019: TornadoFX. Her talk explored how TornadoFX, a Kotlin wrapper around JavaFX, simplifies desktop development with type-safe builders, stylesheets, and the syntactic sugar Kotlin developers appreciate. Liz Keogh’s consultancy work can often be found via lunivore.com.

TornadoFX aims to make JavaFX development more idiomatic and enjoyable for Kotlin developers. It leverages Kotlin’s powerful features to reduce boilerplate and introduce modern development patterns like dependency-injected MVC/MVP. The official website for the framework is tornadofx.io.

Simplifying JavaFX with Kotlin’s Elegance

Liz Keogh’s session highlighted how TornadoFX enhances the JavaFX experience. Key advantages include:
* Type-Safe Builders: Instead of manually instantiating and configuring UI components in JavaFX, TornadoFX provides type-safe builders. This allows for a more declarative and concise way to define UI layouts, reducing the chance of runtime errors and improving code readability.
* Type-Safe Stylesheets: JavaFX typically uses CSS for styling, which is not type-safe and can be cumbersome. TornadoFX introduces type-safe CSS, allowing styles to be defined directly in Kotlin code with autocompletion and compile-time checking. This makes styling more robust and easier to manage.
* Dependency Injection and Architectural Patterns: TornadoFX incorporates support for architectural patterns like Model-View-Controller (MVC) and Model-View-Presenter (MVP) with built-in dependency injection. This helps in structuring desktop applications in a clean, maintainable, and testable way.
* Kotlin’s Syntactic Sugar: The framework makes full use of Kotlin’s features, such as extension functions, lambdas, and DSL capabilities, to create a fluent and expressive API for building UIs.

Liz demonstrated these features through practical examples, showing how quickly developers can create sophisticated desktop applications with significantly less code compared to plain JavaFX.

Practical Application: Building a Desktop Game

To illustrate the power and ease of use of TornadoFX, Liz Keogh built a desktop version of the game “Don’t Get Mad!” (a variant of Ludo/Pachisi) live during her presentation. This hands-on approach allowed attendees to see TornadoFX in action, from setting up the project to building the UI, implementing game logic, and handling user interactions.

She showcased how to:
* Define views and components using TornadoFX’s builders.
* Apply styles using type-safe CSS.
* Manage application state and events.
* Integrate game logic written in Kotlin.

While focusing on TornadoFX, Liz also touched upon broader software development principles, such as the importance of automated testing. She candidly mentioned her preference for unit tests and the need for more in her demo project due to deadline constraints, reminding attendees about the test pyramid. This practical demonstration of building a game provided a tangible example of what’s possible with TornadoFX and how it can accelerate desktop development.

TornadoFX and the Kotlin Ecosystem

Liz Keogh’s presentation positioned TornadoFX as a valuable addition to the Kotlin ecosystem, particularly for developers looking to build desktop applications. By providing a more Kotlin-idiomatic layer over JavaFX, TornadoFX lowers the barrier to entry for desktop development and makes it a more attractive option for the Kotlin community.

She also mentioned another personal project, “K Golf” (Kotlin Game of Life), a JavaFX application she uses for teaching Kotlin, hinting at her passion for both Kotlin and creating engaging learning experiences. Her talk inspired many Kotlin developers to explore TornadoFX for their desktop application needs, showcasing it as a productive and enjoyable way to leverage their Kotlin skills in a new domain. The session underscored the theme of Kotlin’s versatility, extending its reach effectively into desktop development.

Links:

PostHeaderIcon [KotlinConf2018] Advancing Metaprogramming with Kotlin and TornadoFX: Amanda Hinchman-Dominguez’s Exploration

Lecturer

Amanda Hinchman-Dominguez, a Grinnell College ’17 alum, specializes in UI development for sales enablement. With experience at Prudential and Cisco, she is also a sculptor. Relevant links: TornadoFX GitHub (project); LinkedIn Profile (professional page).

Abstract

This article analyzes Amanda Hinchman-Dominguez’s exploration of Kotlin and TornadoFX for metaprogramming, addressing crosscutting concerns in software design. Contextualized in the limitations of Java’s OOP, it examines Aspect-Oriented Programming (AOP) via TornadoFX’s type-safe builders. The analysis highlights innovations in UI automation and test generation, with implications for scalability and modularity.

Introduction and Context

At KotlinConf 2018, Amanda Hinchman-Dominguez presented her early research on Kotlin and TornadoFX, a JavaFX framework leveraging Kotlin’s features. Software complexity demands modular, scalable solutions, but Java’s OOP struggles with crosscutting concerns like logging or UI consistency. TornadoFX’s type-safe builders and Kotlin’s low-ceremony syntax offer a foundation for AOP and metaprogramming, set in the context of her work to automate UI development and testing.

Methodological Approaches to Metaprogramming

Hinchman-Dominguez used TornadoFX’s builders to create declarative UI code, reducing boilerplate. She experimented with metaprogramming to generate UI tests dynamically, collecting data to predict bugs or suggest designs. Her approach involved defining aspects (e.g., validation rules) to separate concerns, using Kotlin’s lambdas and extensions for fluent APIs. Examples included generating UI components and tests, leveraging TornadoFX’s community-driven development.

Analysis of Innovations and Features

TornadoFX innovates with type-safe, declarative UI construction, contrasting Java’s verbose reflection. Kotlin’s lambdas enable AOP-like separation, addressing crosscutting issues. Test generation predicts bugs, a step toward reinforcement learning. Compared to JavaFX alone, TornadoFX simplifies UI logic. Limitations include her project’s early stage and messy code, requiring community contributions for maturity.

Implications and Consequences

This approach implies automated, scalable UI development, reducing repetitive tasks. It could lead to data-driven design tools, enhancing productivity. Consequences include a steeper learning curve for AOP, but open-source collaboration mitigates this, fostering innovation in Kotlin’s ecosystem.

Conclusion

Hinchman-Dominguez’s work with TornadoFX showcases Kotlin’s potential for metaprogramming, paving the way for modular, automated software design with significant future impact.

Links