15
One question that always bothers me when I’m in a Java project where we use Portuguese terms is dealing with method names or variables that represent, somehow, two things and I need to mention both in the method/variable name. In English, and in the same situation, the names get better.
An example, if I am in an English code and have a variable that contains the person’s name and surname, I can have:
firstAndLastName
Simple and easy to read, thanks to And
. But in Portuguese our And
is the E
, which is very bad to read in the code in my opinion, because the uppercase letters end up stuck together:
primeiroESegundoNome
I don’t know about you, but this part ES
gives me a lock on reading any code.
Usually, I end up using one of these alternatives:
primeiroSegundoNome
primeiroComSegundoNome
It solves some cases, it just gets weird in others, but in some it doesn’t solve. Example, if I have a method that checks if the dates exist and are equal, wanting to emphasize this situation, none of the forms below meets well:
hasDatasIguais
hasDatasComIguais
isDatasExistemIguais
isDatasExistemComIguais
In terms of name, it would be better hasDatasEDatasIguais
, hasDatasESaoIguais
*..., but we’re back 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
Boy, I thought only I suffered from it.
– Jéf Bueno
I was curious with the answers you will have to this question, very interesting!! Just one thing, (based on opinion)in the date method I use the
Has
, which in free translation would be "has existing date" rather than "is existing date"– Barbetta
@Barbetta, true. It could be
hasDatasESaoIguais
. I will correct.– Dherik
@Dherik but the "E" is still very strange rsrs ;P
– Barbetta
This is one of the reasons I use English in the name of variables.
– ramaral
This is because the language structures are in English. I find it much easier to read
while not finished
thanwhile not finalizado
, for example.– Woss
I prefer to use English in most cases already because of these occurrences, but can also manipulate a little Portuguese.
primeiroMaisSegundoNome
andexistemDatasIdenticas
, In the last 'exists' case it is not very important in my view, because if they are identical they automatically exist. Unless you are comparing an object. But still...– lazyFox
I wanted to see everything in English on domains that are very local, and on teams that don’t have a deep grasp of English on the subject, which is very common. Native language helps define what is mechanism and what is domain. Not everything needs to be read naturally. And if it’s all in English it’s not always intuitive, it often creates a greater cognitive load. Although really our language is not the most suitable.
– Maniero
@ramaral, I agree, but usually the business terms are in Portuguese, there ends up mixing English with Portuguese inevitably, which also gets strange rs.
– Dherik
I usually use business and domain terms in Portuguese, but I don’t translate code conventions, so I always end up with things like
getCPF
orsetNotaFiscal
- there are those who argue that it should bepegaCPF
orobtemCPF
, But in this particular case, many Apis like JSF always look for getter and Setter automatically and it’s not worth translating these methods. Already business operations (fazIsso
,processaAquilo
) I think it’s best to use the terms the business uses to make things easier. I don’t think there’s a golden rule for that, and it should be examined case by case.– hkotsubo
The @lazyFox comment is exactly the solution I used!
– Tiago Leite
@lazyFox, they may be equal but both null. Hence the emphasis on
existe
:). But it’s just a specific example of the problem withAnd
.– Dherik
Correct, but now it depends on your method of comparison and whether there is a need to consider null
– lazyFox
Relacionados: https://answall.com/questions/301/devo-escrever-meu-programa-em-ingl%C3%Aas-ou-portugu%C3%Aas
– hkotsubo
I also suffer a lot from this doubt. I usually try to change names like "first and second names" to things like "full names". But good question +1
– Wallace Maxters