design icon indicating copy to clipboard operation
design copied to clipboard

Meet them more than halfway and speak their language

Open jennybc opened this issue 6 years ago • 3 comments

Something about writing functions and packages that meet the user halfway -- or more!

This is about default behaviour. It's related to humane defaults for arguments but on a larger scale. Be willing to take instructions in the user's preferred terminology and translate it to what the computer requires, internally, without pedantry or drama.

An example of the principle I have in mind is how ggplot2::ggsave() can infer figure file format from the extension of the putative file name. There are some other really humane touches to this function. This was one of my most delightful discoveries when I switched to ggplot2 from base/lattice

A good base R example is the ability to specify legend location from the keywords "bottomright", "bottom", "bottomleft", "left", etc. instead of, e.g., 1, 2, 3, or 4 (par(mar)). The whole notion of a formula interface may also qualify.

My plan for this issue is to use it to collect more positive negative and examples of this principle.

jennybc avatar Mar 09 '19 16:03 jennybc

A possible small example: the ggplot2::margin() function is a very thin wrapper around unit(), but it's argument names (and hence autocomplete help) remind you which order the margins are expected in.

hadley avatar Mar 09 '19 19:03 hadley

Counterpoint: having too many different ways to specify something makes it harder to read later. Line types might qualify with three ways to specify each type.

hadley avatar Mar 31 '19 21:03 hadley

This tweet/slide captures what I am trying to get at:

https://twitter.com/antgoldbloom/status/1116137618511552512

D31RPtrU8AAXcCE

jennybc avatar Apr 11 '19 02:04 jennybc