[tor-bugs] #28114 [Metrics/Library]: Improve getter names for boolean fields in metrics-lib
Tor Bug Tracker & Wiki
blackhole at torproject.org
Tue Oct 30 23:19:20 UTC 2018
#28114: Improve getter names for boolean fields in metrics-lib
-----------------------------+------------------------------
Reporter: efgyirfe784 | Owner: metrics-team
Type: enhancement | Status: new
Priority: Medium | Milestone:
Component: Metrics/Library | Version:
Severity: Normal | Resolution:
Keywords: | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
-----------------------------+------------------------------
Comment (by efgyirfe784):
Good point about the keywords. Where can I find dir-spec.txt?
I do like the flow of dropping the getters as the client code sounds
natural:
{{{
if (o.usesEnhancedDnsLogic()) {}
if (o.cachesExtraInfo()) {}
if (o.allowSingleHopExits()) {}
if (o.tunnelledDirServer()) {}
}}}
This could become confusing if setters are ever created in the future, but
I'm guessing that's not too likely.
Keeping a simple rule like "prefix any keyword with 'get' and that's the
method name to retrieve the keyword value" is probably more important than
using more meaningful English-sounding method names or even more natural
sounding client code, since it makes library users' lives easier. If
determining the method to retrieve a keyword now depends on the type being
returned, things become more complicated for library users.
It looks like some Descriptors already use an "is" prefix for boolean
return types though:
{{{
RelayNetworkStatusVote.isSharedRandParticipate()
ServerDescriptor.isHibernating()
ServerDescriptor.isHiddenServiceDir()
}}}
(some non-Descriptors also use "is" prefix for boolean return types)
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/28114#comment:7>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list