What is the 'And' alternative in Portuguese for variable names and methods?

14

A question that always teases me when I'm in a Java project in which we use terms in Portuguese is to deal with method names or variables that represent somehow two things and need to mention both in the method / variable name. In English, and in the same situation, the names get better.

An example, if I'm in an English code and I have a variable that contains the person's first and last name, I can have:

firstAndLastName

Simple and easy to read, thanks to And . But in Portuguese our And is E , which is very bad to read in the code in my opinion, because the capital letters end up stuck:

primeiroESegundoNome

I do not know about you, but this part ES gives me a hang on reading any code.

I usually end up using one of these alternatives:

primeiroSegundoNome
primeiroComSegundoNome

Resolve in some cases, it is only strange in others, but some do not solve. For example, if I have a method that checks whether the dates exist and are the same, wanting to emphasize this situation, none of the following forms serve well:

hasDatasIguais
hasDatasComIguais
isDatasExistemIguais
isDatasExistemComIguais

In terms of the name, it would look even better hasDatasEDatasIguais , hasDatasESaoIguais * ..., but we return to the initial problem.

Is this a problem that bothers you too? How do you act in similar cases?

* Here I mixed the English term has with Portuguese, but this is another subject

    
asked by anonymous 17.05.2018 / 15:15

1 answer

11

First option: accept that it hurts less :) If you have a pattern when you hit the eye in two consecutive capital letters, even one being E will already quickly connect what it is after some training.

You can also use some bad variations

isDatasExistemTambemIguais //Fica longo, mas aceitável
isDatasExistemTbIguais  //Menos legível, mas nada crítico
isDatasExistemE_Iguais //Foge do padrão normalmente usado, mas resolve
isDatasExistemAndIguais //Esquisito, mas válido, há precedente
isDatasIguaisSeExistirem  //Questão se interpretação
isDatasExistentesMasIguais //Mais para ter opções

You can make other combinations from these.

But as E can be implied in some situations it is easier to rewrite, I would get

TemDatasIguais

If there is no one or more dates implies that they are not equal. Of course if all do not exist until we can say that they are equal, but in a certain way they are not even compared.

If there really could be a situation where the concatenation needs to be explicit there would have to use some other word, or accept the oddity that is the casing .

I would use Eh or É instead of is . At first I think casing is less important, and the accent helps to differentiate. See: Is there a problem using Unicode characters for handles in code? .

  

I can remember something else.

    
17.05.2018 / 15:39