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

Rename NewService to New #8337

Merged
merged 9 commits into from
Jan 26, 2021
Merged

Rename NewService to New #8337

merged 9 commits into from
Jan 26, 2021

Conversation

terencechain
Copy link
Member

What type of PR is this?

Clean up

What does this PR do? Why is it needed?

Addressing feedback from #8320

If the package name describes the object being created, then the constructor name should be New, to avoid duplication. Example: service.New vs service.NewSevice (the function returns a Service struct). Otherwise, the name should be NewXyz. Example: helpers.NewSlotTicker vs helpers.New. Seeing helpers.New does not tell you anything about what's being created.

Which issues(s) does this PR fix?

N/A

Other notes for review

N/A

rkapka
rkapka previously approved these changes Jan 26, 2021
Copy link
Contributor

@rkapka rkapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if you plan to comb through the whole project looking for similar patterns, but one that I found is NewBeaconNode in beacon-chain/node/node.go that can be simplified to New. I'm sure there are similar cases with other node types. We have several node.go files, so it might be a good idea to also go through them.

slasher/detection/service.go Outdated Show resolved Hide resolved
@prylabs-bulldozer prylabs-bulldozer bot merged commit d121b19 into develop Jan 26, 2021
@delete-merged-branch delete-merged-branch bot deleted the rename-functions branch January 26, 2021 10:27
rkapka added a commit that referenced this pull request Feb 12, 2021
This reverts commit d121b19.

# Conflicts:
#	beacon-chain/sync/initial-sync/round_robin_test.go
prylabs-bulldozer bot added a commit that referenced this pull request Feb 12, 2021
* Revert "Rename `NewService` to `New` (#8337)"

This reverts commit d121b19.

# Conflicts:
#	beacon-chain/sync/initial-sync/round_robin_test.go

* fix name in test

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
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.

2 participants