-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid character returns in wb
functions
#378
Comments
I don't see anything wrong with the
|
I've pushed a draft of my idea here: #379 (just something that compiles and returns something. With this PR both chunks above return a workbook. They use the three fields:
This way |
Mentioning that that the messages field is likely not stable, though I do like the idea of some history tracking. Maybe log might be a better naming? I'm not sure I quite understand the returns value. Does that mean wb$get_authors() is going to return the wbWorkbook object invisibly and not a character vector for authors? I don't think managing multiple return values is going to be very pleasant The $get_*() methods should be clear enough that they don't return the wbWorkbook object but instead a field or some other sort of attribute. They wouldn't make sense piped: wb <-
wb_workbook() |>
wb_add_worksheet() |>
wb_add_data() |>
# what would this do? how do I get the authors?
# if it is only saving the value to `results` then it's more of a
# _store_ or _catch_.
wb_get_authors() |>
wb_add_worksheet() |>
wb_add_data()
# access directly? no means of performing checks, validations:
wb$authors
# access with another function? feels redundant to have to get the value then get it again
wb |>
wb_get_authors() |>
wb_get_result("authors")
# current methods are essentially accessing directly but can contain
# some additional checks and validations
wb$get_authors()
wb_get_authors(wb) |
sorry replaced your comment 🤦 This is what I had in mind: we could wrap it in functions not called wb_. Though until now it was just an idea and a quick draft. wb |>
wb_get_authors() |>
wb_get_result() Or wb |> get_authors() |
I often accidentally delete my own comments! To me, the |
For me this is about predictable code. If I am surprised by the output as author, what else can I expect from the user.
|
Certain
wb
functions return character strings. Recently stumbled over this here:I expected
wb
to remain a workbook, but it had turned into a string withwb_save()
.Another case where a
wb
function returns something other than awbWorkbook
iswb_get_cell_styles()
:I'm wondering, if we should avoid this. I'm thinking about something like a path and message field, where we store the path we read from and save to.
The text was updated successfully, but these errors were encountered: