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

Better naming for constructor funcs #7316

Merged
merged 12 commits into from
Sep 23, 2020
Merged

Better naming for constructor funcs #7316

merged 12 commits into from
Sep 23, 2020

Conversation

farazdagi
Copy link
Contributor

What type of PR is this?

Other / Better naming for initializing funcs

What does this PR do? Why is it needed?

  • A package name and its contents' names are coupled, since client code uses them together. Therefore, conventionally, we prefer the following:
    • initsync.NewService() instead of initsync.NewInitSyncService() (both to avoid stuttering and because when some constructor returns type T, if type doesn't coincide with package name it is conventional to name it NewT(), not NewSomePartOfPackageNameT()). For the most of our services, we do indeed have service.NewService() - for those diverging, this PR provides a fix.
    • When package name and returned type do indeed coincide, the conventional naming is just New(). That's instead of wallet.NewWallet() (for function that returns *Wallet i.e. name of returned type and package coincide), we'd prefer wallet.New() (and expect it return Wallet or `*Wallet). This PR fixes number of such occurrences.

Which issues(s) does this PR fix?

N/A

Other notes for review

@farazdagi farazdagi self-assigned this Sep 23, 2020
@farazdagi farazdagi marked this pull request as ready for review September 23, 2020 08:04
@farazdagi farazdagi requested a review from a team as a code owner September 23, 2020 08:04
@codecov
Copy link

codecov bot commented Sep 23, 2020

Codecov Report

Merging #7316 into master will decrease coverage by 0.10%.
The diff coverage is 78.94%.

@@            Coverage Diff             @@
##           master    #7316      +/-   ##
==========================================
- Coverage   60.02%   59.92%   -0.11%     
==========================================
  Files         416      416              
  Lines       29950    29857      -93     
==========================================
- Hits        17978    17891      -87     
- Misses       9032     9038       +6     
+ Partials     2940     2928      -12     

@prylabs-bulldozer prylabs-bulldozer bot merged commit 3621b2f into master Sep 23, 2020
@delete-merged-branch delete-merged-branch bot deleted the better-naming branch September 23, 2020 08:59
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