Hadley Wickham - Pure, predictable, pipeable: creating fluent interfaces with R


Details
Dear Members:
On Wednesday 18 November, the University of Auckland Department of Statistics is pleased to welcome Hadley Wickham as speaker for a special talk in our seminar series, and we invite you to attend. Please join us for refreshments afterwards in the break out space on Level 3.
Special Thanks to Jesse Goodman from Department of Statistics, University of Auckland.
Abstract:
A fluent interface lets you easily express yourself in code.
Over time a fluent interface retreats to your subconcious. You don't need to bring it to mind; the code just flows out of your fingers. I strive for this fluency in all the packages I write, and while I don't always succeed, I think I've learned some valuable lessons along the way.
In this talk, I'll discuss three guidelines that make it easier to develop fluent interfaces:
-
Pure functions. A pure function only interacts with the world through its inputs and outputs; it has no side-effects. Pure functions make great building blocks because they're are easy to reason about and can be easily composed.
-
Predictable interfaces. It's easier to learn a function if it's consistent, because you can learn the behaviour of a whole group of functions at once. I'll highlight the benefits of predictability with some of my favourite R "WAT"s (including 'c()', 'sapply()' and 'sample()').
-
Pipes. Pure predictable functions are nice in isolation but are most powerful in combination. The pipe, '%>%', is particularly important when combining many functions because it turns function composition on its head so you can read it from left-to-right. I'll show you how this has helped me build dplyr, rvest, ggvis, lowliner, stringr and more.
This talk will help you make best use of my recent packages, and teach you how to apply the same principles to make your own code easier to use.
Cheers,

Hadley Wickham - Pure, predictable, pipeable: creating fluent interfaces with R