Skip to content

Standardise getters, setters and updaters #5568

@teunbrand

Description

@teunbrand

There are various functions that get or set things, but the names aren't standardised.
Some example getter functions are:

layer_data()
layer_grob()
layer_scales() # these aren't really related to layers?
theme_get()
last_plot()
get_alt_text()

Some example setter functions are:

theme_set()
set_last_plot()

Some example of updater functions are:

update_geom_defaults()
update_stat_defaults()
theme_update()
add_ggplot()/ggplot_add()

The non-standardisation of these functions confuse the API somewhat. For example theme_bw() is a theme in its own right but theme_get() is an interface to the global theme. Likewise, layer_sf() is a specialty layer, whereas layer_data() is not a layer.

I'd like to propose that these type of functions always use a get_, set_ or update_ prefixes so that it is easy to see what getters, setters and updaters are available through tab-completion.

For example we'd have:

get_layer_data()
get_layer_grob()
get_scales()
get_theme()
get_last_plot()
get_alt_text() # identical
set_theme()
set_last_plot() # identical
update_theme()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions