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

Windy City DevFest - Kotlin: The Next Frontier ...

mvndy_hd
February 01, 2019

Windy City DevFest - Kotlin: The Next Frontier for Modern (Meta) Programming

Since Google declared Kotlin as the official language for Android, Kotlin has become one of the fastest growing languages in the coding world and current projections forecast continued increased global use. One year ago, I started using Kotlin to help me solve everyday problems in the office. Then I wrote a programmatic wizard for sales people to generate live demos for prospective clients because, well, I’m lazy.

I ended up writing my own drag-and-drop functionality because I didn’t know how to serialize my custom objects; the problem was that I was having a tough time debugging my micromanaged events, and I realized I needed testing for the UI. The other problem? I had no idea how to write UI tests. I thought— what if I used metaprogramming to generate these tests for me?

So I set out to ask other developers and QA engineers:

- What makes a good test?
- What makes a bad test?

TornadoFX-Suite started out with simply generating TornadoFX UI tests. But there’s more to it than that. If this project can be used by multiple people for multiple frameworks — could we collect that data and use machine learning to find these answers? The natural progression from metaprogramming is machine learning. Kotlin is not quite ready to call itself a data stack yet, but it has already started addressing the necessary components for a robust and stable software needed handle & analyze large data systems.

This talk is an exploration in the philosophy of what makes an application, how we can formalize that philosophy in an abstraction of contract and property-based testing, and how we can use Tensorflow to help us find suggestive data points between the effectiveness of the tests we write and the circumstances surrounding the project being tested.

mvndy_hd

February 01, 2019
Tweet

More Decks by mvndy_hd

Other Decks in Technology

Transcript

  1. Kotlin: The Next Frontier for Modern (Meta) Programming Amanda Hinchman-Dominguez

    @hinchman_Amanda mvndy UI Testing, Metaprogramming, and Deep Learning with TornadoFX
  2. A UI Test goes something like this… Grab a particular

    view Perform an action on that view Check the UI to see if it looks as it should
  3. A UI Test goes something like this… Grab a particular

    view Perform an action on that view Check the UI to see if it looks as it should
  4. Saving UI Controls • Define a dictionary of UI controls

    we care about • Use AST parsing to recurse down the lambdas until one matches any dictionary term • Save the hierarchy of the nodes by saving them in a digraph
  5. A UI Test goes something like this… Grab a particular

    view Perform an action on that view Check the UI to see if it looks as it should
  6. Dynamically Attaching Ids to the View • Many folks do

    not attach ids to their node components • Metaprogramming can use the saved nodes, generate random ids and attach them at runtime
  7. A UI Test goes something like this… Grab a particular

    view Perform an action on that view Check the UI to see if it looks as it should if it changes
  8. Kotlin & Data Science: A Budding Love Story • Static-typing

    and null-safety increases runtime stability • Kotlin lends itself to concurrency and parallelism • Kotlin is a functional paradigm • Encourages immutability • Kotlin coroutines
  9. What makes a good UI test? Grab a particular view

    Perform an action on that view Check the UI to if it changes if it looks as it should
  10. Deep learning with Tensorflow Java API • Keras – model-level

    library that provides a high-level API for interfacing with Tensorflow • Tensorflow – deep-learning computation engine while Keras serves as a front-end client
  11. The Essence of Deep Learning • Transformations of data are

    geometric in nature • Finding transformations that turn data into more-useful representations Jeff Nyman’s Demystifying Machine Learning
  12. The Mechanics of Deep Learning, under the hood Tensors are

    the key data structure for deep learning; but we’re really just talking about operations on matrices. Jeff Nyman’s Demystifying Machine Learning
  13. The Deep “Learning” Lifecycle Gather & Prepare Data Define the

    Model Compile the Model Train (Fit) the Model Execute the Model Make Predictions from the Model
  14. But is it really learning? Gather & Prepare Data Define

    the Model Compile the Model Train the Model Execute the Model Make Predictions from the Model Still room for a human element
  15. Criticisms of Machine Learning Today • Jargon obfuscates meaning •

    Forces us to accept jargon as ”truths” without analyzing the mechanics • ML makes an emphasis on extracting away irrelevant details for fear of: • “Overfitting/Underfitting”: • We build the weights as we see things; we don’t let those things emerge.
  16. Curiosity-Driven Learning • Introduced 2017 by the University of California,

    Berkeley • Curiosity-driven Exploration by Self- Supervision (2017) • Large-Scale Study of Curiosity Driven learning • Model intrinsic rewards from curiosity • Curiosity-driven learning agents were able to generalize better with unexplored environments.
  17. Curiosity- Driven Learning with Tensorflow Create many models Address sequential

    data feeds by permuting the order in different models Observe trends See what trends (weights) emerge Data Mining Creating a data lake
  18. TornadoFX-Suite: Creating a data lake • Shape/ depth of UI

    hierarchies • Positive v Negative space • Code coverage • Number of: • Commits • Contributors • Data would be formatted in 2D matrices represented by numbers
  19. • Creating permutations of interactions, and training models to learn

    what patterns may correlate to certain expectations • Tracking trends with tests that passes/fails • Puts pressure on design Locating properties worth testing
  20. • Displaying visual analysis by property can help us discover

    classifications • This modified approach of machine learning can help provide decision boundaries • allows us to make decisions about data Curiosity-Driven Learning à Property-Based Testing Jeff Nyman’s Demystifying Machine Learning
  21. Relevant Links • Kastree: https://github.com/cretz/kastree • Gson: https://sites.google.com/site/gson/ • Tensorflow:

    https://www.tensorflow.org • Data Science Crash Course: https://github.com/ahinchman1/Data-Science- Crash-Course • Demystifying Machine Learning w/ Jeff Nyman: http://testerstories.com/2018/09/demystifying-machine-learning-part-1/ • Curiosity-Driven Learning: https://pathak22.github.io/noreward- rl/resources/icml17.pdf