Wednesday, January 29, 2014

What are the best words to describe subjects being compared?



I tried to Google this but no luck so far. I was wondering if there was proper words to describe the comparison of 2 subjects?




  1. The first subject would be the object being compared in relation to

    the other (the baseline).

  2. The second subject would be the object compared to the first one.



So you could say, subject 1 is taller than subject 2 for example.



Do we say subject 1 is the subject of comparison and subject 2 is the comparee? I saw some scientific article using the word comparee but it doesn't sound proper to me.







Given the topic, I am updating this question with more context so that it is less confusing. It looks like comparison subjects can have quite a few different names depending on their context. Here is the context I'm looking for (watch out for the pseudocode - yes I'm know I'm not on Stackoverflow...):



function isGreater(subject1, subject2) {
if (subject1 > subject2) {
return true;
}
return false;
}




More precisely, I'm looking for the left/right words (subject1/subject2) which would be the most semantically correct. We're also presuming that the order does not change and that is example is way much simpler than what I'm trying to solve (which is why semantic variable names make sense).



Please help!


Answer



After several interesting conversation in the post's comments, I got creative and found names for my use case which make most sense for me. While I understand that given the nature of the question it looks almost like at this point this is more of a personal preference than a black and white answer, I will share my thought process.



Based on my use case, concerns comparing two variables from which one is the left and the other is the right in a greater than (>) comparison, I could have picked leftElement and rightElement. While they make sense from a comparison perspective, I find that if looked at in a big block of code, they would be hard to understand.



I preferred to pick referenceElement and comparedElement. The idea behind that is that the first one is the one used as reference for the comparison and the second one is the one we use to compare. While I also understand that there could be context calling this function with a variable named reference which would be used in the right side, I think that local context takes precedence on these situation for better readability. Any good developer should know the different between local variables and their scopes.




Also to give more context, the objects which I use to compare in this function are HTML element, hence the element but I could have picked something else in a different context.


No comments:

Post a Comment