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

Getter naming #6562

Closed
trask opened this issue Sep 8, 2022 · 4 comments · Fixed by #7619
Closed

Getter naming #6562

trask opened this issue Sep 8, 2022 · 4 comments · Fixed by #7619

Comments

@trask
Copy link
Member

trask commented Sep 8, 2022

Sometimes we use getAbc() and sometimes abc().

I believe the core repo went with getAbc() everywhere(?).

Can we come up with explanation of when to use one vs the other?

E.g. here's one class where we use both (which may be ok, but I'd like to be able to write down the reason)

@Nullable
public abstract InetSocketAddress getAddress(REQUEST request, @Nullable RESPONSE response);
@Override
@Nullable
public final String peerName(REQUEST request, @Nullable RESPONSE response) {

@mateuszrzeszutek
Copy link
Member

Sometimes we use getAbc() and sometimes abc().

I believe the core repo went with getAbc() everywhere(?).

Can we come up with explanation of when to use one vs the other?

I think we might have done that somewhat by accident, I don't think it was a conscious decision to use the abc() format.
We should go with getAbc(), since that's what we use in both SDK and instrumentation-api.

@trask
Copy link
Member Author

trask commented Sep 11, 2022

Just a note: one place where we don't use get (and core repo doesn't use get either) is builder() methods (and their friends like spanBuilder(), tracerBuilder(), etc

@trask
Copy link
Member Author

trask commented Sep 11, 2022

More notes:

Static methods on interfaces:

  • IdGenerator.random()
  • SpanProcessor.composite(...)
  • SpanContext.getInvalid()
  • SpanId.getInvalid()

I'd say that maybe random() should have been getRandom() (or getDefault()), but composite(...) makes sense (it's more like a builder), and we follow similar with AttributesExtractor.constant(...)

@mateuszrzeszutek
Copy link
Member

I think we usually use <noun>() in static factory methods -- I think it's fine, it reads in a more "declarative" way

mateuszrzeszutek pushed a commit that referenced this issue Jan 23, 2023
…7619)

Resolves #6562

This PR only contains renames; the actual content is in the `*Getter`
interfaces, the rest of changes is just IntelliJ doing its job.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants