vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
196 stars 16 forks source link

Prefix functions with `tt_` #217

Closed eyayaw closed 6 months ago

eyayaw commented 6 months ago

Firstly, thank you for such a wonderful package.

While experimenting with it, I noticed that the tinytable functions are not easy to find because they are suffixed _tt rather than prefixed by tt_. Is this a deliberate choice? I think it would be nice to prefix them with tt_ so that it is easier not only to find functions but also to leverage IDE's autocomplete feature.

If you have a family of functions that do similar things, make sure they have consistent names and arguments. Use a common prefix to indicate that they are connected. That’s better than a common suffix because autocomplete allows you to type the prefix and see all the members of the family.

--- R4DS: https://r4ds.had.co.nz/functions.html#functions-are-for-humans-and-computers

vincentarelbundock commented 6 months ago

Hmm, that's actually a good point I had not considered.

I could potentially export aliases with the prefix, and then decide if we want to move there long term.

Let me think about it a bit.

vincentarelbundock commented 6 months ago

I thought about this. The discoverability point is a good one, but the package only has a few functions, so it is trivial to look at the docs, or to type tinytable:: and then TAB in any editor to get a list of exported functions by completion.

I considered adding aliases to all functions, but this would double the number of exports and make the docs less readable.

I considered switching the order for all functions: group_tt()->tt_group(), style_tt()->tt_style().

But this would be a major breaking change. Also, I'm not convinced that the argument in your link fully applies here. The major difference is that we are now thinking about a prefix that would apply to every single function of the package. That's what the namespace is for!

Finally, I think this is more readable:

tt(x) |>
  group_tt() |>
  style_tt()

thank this:

tt(x) |>
  tt_group() |>
  tt_style()

Sorry I didn't give you what you wanted, but feel free to open more feature requests and I promise I'll consider them seriously.

eyayaw commented 4 months ago

Thank you for considering it.

I am not sure whether the argument in the link is convincing. However, as you well know, there are several packages that follow such styles: stringi, stringr, ggplot2 (geom_*, theme_*), sf, tmap, etc. Regarding breaking changes, if you find the argument convincing, I think it is better to do it early rather than later.

vincentarelbundock commented 4 months ago

Thanks for the nudge, but I won't change this.