RMI-PACTA / r2dii.plot

A package containing functions to create standard 2DII plots using ggplot, together with data processing functions needed for the charts.
https://rmi-pacta.github.io/r2dii.plot
Other
8 stars 4 forks source link

Why have the design-pattern `function()` with the body `function_impl()`, defined elsewhere? #529

Open jdhoffa opened 7 months ago

jdhoffa commented 7 months ago

For example, in the file scale_colour_r2dii.R, there is a function defined as r2dii_pal, that has an abort call and a body of r2dii_pal_impl that is defined in a different file utils.R.

What are the pros to doing this?

The main cons I notice are that context shifting (and not being able to directly see what a function does when looking at it) takes time and makes it difficult to interpret what a function does.

jdhoffa commented 6 months ago

I think the last place this appears is here: https://github.com/RMI-PACTA/r2dii.plot/blob/ec42cf33fb7d07788ed8513fe753073e9c2e167d/R/utils.R#L282-L291