Skip to content
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

API updates for v0.5: the renamening #59

Merged
merged 4 commits into from
Jul 2, 2020
Merged

Conversation

warpfork
Copy link
Collaborator

Several API naming changes that have been buffered and planned for a while are now getting applied. :D

The CHANGELOG diff says it as well, but for recap in github's PR UI:

  • Renamed: NodeStyle -> NodePrototype.
    • Reason: it seems to fit better! See Rename NodeStyle to NodePrototype #54 for a full discussion.
    • This should be a "sed refactor" -- the change is purely naming, not semantics, so it should be easy to update your code for.
    • This also affects some package-scoped vars named Style; they're accordingly also renamed to Prototype.
    • This also affects several methods such as KeyStyle and ValueStyle; they're accordingly also renamed to KeyPrototype and ValuePrototype.
  • Renamed: (Node).Lookup{Foo} -> (Node).LookupBy{Foo}.
    • Reason: The former phrasing makes it sound like the "{Foo}" component of the name describes what it returns, but in fact what it describes is the type of the param (which is necessary, since Golang lacks function overloading parametric polymorphism). Adding the preposition should make this less likely to mislead (even though it does make the method name moderately longer).
    • This should be a "sed refactor" -- the change is purely naming, not semantics, so it should be easy to update your code for.
  • Renamed: (Node).Lookup -> (Node).LookupNode.
    • Reason: The shortest and least-qualified name, 'Lookup', should be reserved for the best-typed variant of the method, which is only present on codegenerated types (and not present on the Node interface at all, due to Golang's limited polymorphism).
    • This should be a "sed refactor" -- the change is purely naming, not semantics, so it should be easy to update your code for. (The change itself in the library was fairly literally s/Lookup(/LookupNode(/g, and then s/"Lookup"/"LookupNode"/g to catch a few error message strings, so consumers shouldn't have it much harder.)
    • Note: combined with the above rename, this method overall becomes (Node).LookupByNode.
  • Renamed: ipld.Undef -> ipld.Absent, and (Node).IsUndefined -> (Node).IsAbsent.
    • Reason: "absent" has emerged as a much, much better description of what this value means. "Undefined" sounds nebulous and carries less meaning. In long-form prose docs written recently, "absent" consistently fits the sentence flow much better. Let's just adopt "absent" consistently and do away with "undefined".
    • This should be a "sed refactor" -- the change is purely naming, not semantics, so it should be easy to update your code for.

All of these changes are simple renames. The compiler should highlight them instantly for anyone updating their use of this library; the fixes to consuming code are trivial to apply; and this should generally be easy to absorb.

Nonetheless, since they're technically "breaking" changes, you'll find that v0.4 was tagged immediately before the start of this branch; and I'll be tagging a v0.5 as soon as this branch merges to master. This should make it easier to step through just these changes (and nothing else) all at once, at the consumer's leisure.

warpfork added 4 commits June 26, 2020 13:51
... and it will further become LookupByNode shortly, but that will be
a separate commit.

See the changelog for discussion; this had already been on the docket
for a while now.
See the changelog for discussion; this had already been on the docket
for a while now.
Hopefully this increases clarity and eases comprehension.

Notes and discussion can be found at
#54 (and also
I suppose in some of our weekly video chats, but I'd have
to go on quite a dig to find the relevant links and time).

Many many refernces to 'ns' are also updated to 'np',
making the line count in this diff pretty wild.
@codecov
Copy link

codecov bot commented Jun 29, 2020

Codecov Report

Merging #59 into master will not change coverage.
The diff coverage is 24.06%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #59   +/-   ##
=======================================
  Coverage   42.36%   42.36%           
=======================================
  Files          89       89           
  Lines        7518     7518           
=======================================
  Hits         3185     3185           
  Misses       4194     4194           
  Partials      139      139           
Impacted Files Coverage Δ
node/basic/bool.go 0.00% <0.00%> (ø)
node/basic/bytes.go 0.00% <0.00%> (ø)
node/basic/float.go 0.00% <0.00%> (ø)
node/basic/int.go 2.77% <0.00%> (ø)
node/basic/link.go 0.00% <0.00%> (ø)
node/gendemo/tInt.go 0.00% <0.00%> (ø)
node/gendemo/tMap__String__Msg3.go 0.00% <0.00%> (ø)
node/gendemo/tMsg3.go 0.00% <0.00%> (ø)
node/gendemo/tString.go 0.00% <0.00%> (ø)
node/mixins/boolMixin.go 0.00% <0.00%> (ø)
... and 58 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cedbb05...75d7491. Read the comment docs.

@warpfork warpfork merged commit cbb6dbc into master Jul 2, 2020
@warpfork warpfork deleted the api-naming-improvements branch July 2, 2020 05:31
@warpfork
Copy link
Collaborator Author

warpfork commented Jul 2, 2020

Merged; and v0.5 is now tagged on master 🎉

@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant