-
Notifications
You must be signed in to change notification settings - Fork 9
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
Unify naming of ValueExpression instances #274
Comments
jvdb
added a commit
that referenced
this issue
Dec 17, 2018
…to the defined naming scheme around ValueExpression instances.
jvdb
added a commit
that referenced
this issue
Dec 21, 2018
jvdb
added a commit
that referenced
this issue
Dec 21, 2018
jvdb
added a commit
that referenced
this issue
Dec 21, 2018
jvdb
added a commit
that referenced
this issue
Dec 21, 2018
jvdb
added a commit
that referenced
this issue
Dec 24, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The smells (from Sonar) about hiding field names with variables actually expose that our naming scheme is a little messy. We often have this problem where we have a
ValueExpression
operand calledsomething
and then do this:final ImmutableList<Optional<Value>> something = this.something.eval(parseState, encoding);
Which then hides the field. I understand why because after the
eval()
-call it's more or less the new version of the same value that we use from then on. But it may still be error-prone if we ever somehow want to use the field again (e.g., for another different evaluation).Additionally, we use different naming schemes in some locations, like calling the variable
somethingValues
orevaluatedSomething
.In addition to this, there is a distinction between
ValueExpression
s where we are capable of processing a list of evaluated values and where we explicitly forbid returning a list and only accept a single, non-empty value (e.g., thesize
argument onDef
). Still, we tend to name both types using singular nouns instead of plurals. With the singular values, we often also extract the final value, often as anint
orBigInteger
.My proposal is to unify everything using the following style (example is from
Expand
, which has a plural argument (base
) and a singular one (count
)):bases
andcount
.2.
When evaluating the fields, prefix the names withIt's probably better to name these things -evaluated
, so in this caseevaluatedBases
andevaluatedCount
.list
instead ofevaluated
-. So it would then bebaseList
andcountList
.Values
to in this casebaseValues
. There seems to be no reason to passevaluatedCount
around as a list (see next item). Not sure whether we should keep this or keep using thelist
-suffix.Value
, so in this casebaseValue
(for example to bind a variable when iterating the list) andcountValue
.The only question that remains is what we do with the many instances of the names
operand
,left
andright
? In many cases with basic operators there are no other names for the operands. But should we rename the cases where lists are acceptable then to useoperands
,lefts
andrights
? It somehow feels a bit weird, but it is the direct consequence of this naming scheme.Originally posted by @jvdb in #273 (comment)
As discussed in #275, there are some problems with this proposal and we've decided:
multipliers
(instead ofleft
) andmultiplicands
(instead ofright
) for the operands ofMul
.BinaryValueExpression
) then we use generic names such as 'left', 'right' and 'operand'.All in all I would say we prefer a bit more pragmatic approach to naming things.
The text was updated successfully, but these errors were encountered: