Skip to content

Rename functions to match the Tidyverse style #208

Closed

Description

@GegznaV

In the tidyverse style guide, sections on object names and function names (2.1 Object names; 3.1 Naming; very short sections, so you can read them now) suggest that function names contain only letters, digits, and underscores. Dots . are advised to be used only for S3 methods. Capital letters should be avoided too.

Some of the function names in hyperSpec do not comply with these style rules even though CONTRIBUTING.md states that

  • This project adheres to the Tidyverse styleguide.

I see an inconsistency here.

Some of the possible suggestions what could be done:

  1. To rename some/most of the function names (except additional methods for base or other packages, e.g., as.data.frame.hyperSpec()), that names do not comply with the tidyverse style and have two versions of function names for backward compatibility.
  2. The same as (1) but deprecate the names that do not comply with the style.
  3. Update CONTRIBUTING.md that all new functions must comply with the tidyverse style, but the package has functions that do not in order to avoid breaking changes.
  4. / other options are also possible /

My personal position is to rename at least some of the functions. Especially, spc.* and normalize.* series.
(The read.* and write.* series might also be renamed). And now (before splitting hyperSpec into separate packages and releasing 1.0.0, as major release means that breaking changes are introduced.

image

image


P.S. If there is a question about styler package, it only does those changes that do not break the code. I.e., it does not rename functions. Thus, this issue is not related to styler.

Activity

  1. added
    Topic: style ✏️
    on Jul 13, 2020
  2. self-assigned this
    on Jul 15, 2020
  3. added this to the Version 1.0 milestone on Jul 15, 2020
  4. GegznaV commented on Jul 15, 2020

    @GegznaV
    CollaboratorAuthor

    The functions can be renamed, but the old names should be properly deprecated.

  5. cbeleites commented on Jul 24, 2020

    @cbeleites
    Owner

    I see the tidyverse style as a recommendation, i.e. nothing to follow blindly.

    • I'm fine with naming new functions in snake_case.
    • OTOH, we will anyways have a mix of naming styles since we need to adhere to the spelling of any function we import/overload. Thus, I don't see any urgency in renaming functions for the sake of having some more snake_case.
    • The read.*() functions can be renamed to read_*() when moving them into their new packages, though.
    • The ggplot2-related functions should IMHO be renamed when moving into their own package, since ggplot2 belongs to the tidyverse and itself uses snake_case. Other names would be more surprising than usual here.
    • As we discussed in the video meeting on 2020-07-20, function names refering to manufacturers/companies, software, standards or abbreviations should use the common/proper spelling of those rather than lower casing it.
  6. GegznaV commented on Aug 31, 2020

    @GegznaV
    CollaboratorAuthor

    I'm going to rename some functions by following these principles:

    • use Tidyverse style, where possible;
    • use more meaningful/consistent function names (Rename functions (4): helpers #302);
    • use a common prefix for certain types of functions (when applicable; in some cases this requres rearanging function name parts):
    • do not use a prefixed dot for exported functions.
  7. changed the title [-]Should function names in hyperSpec adhere to the tidyverse style?[/-] [+]Rename functions to match the Tidyverse style[/+] on Sep 1, 2020
  8. GegznaV commented on Jul 12, 2021

    @GegznaV
    CollaboratorAuthor

    I'm closing this issue as there were more specific issues (listed above) opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Note: guidelineTopic: rename ♻️Topic: style ✏️

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions