Forget about this good practice business. You have to do the right thing for every situation. As I do not know the context of this situation I can not speak what is ideal to do in it.
This whole code is weird. If it was a real code maybe it would give you a better word.
I do not particularly create variables that will be used only once unless it is too complex a code and a separation helps legibility, a variable serves to document the code in these cases.
There are people who love creating a lot of variable to document, create more than one in this case. One thinks explicitly everything is the most important for readability, spatially Java programmers. De Groovy should not already be a more drawn language for scripts . It's a matter of culture.
I like to analyze each case and see what is best and for me the best by default is short code, with few tokens , until it proves necessary to have tokens in> to stay more readable. My code would look like this:
private fazerAlgo(AlgumaCoisa algumaCoisa) {
Utilidades.converter(formatador.formatarParaTal(algumaCoisa.a, algumaCoisa.b, algumaCoisa.c))
}
Mainly in Groovy. I would love for this formatarParaTal()
to accept the object and it would take the elements, but I do not know if it is possible in this "case".
So it's taste, it's style choice. Preferably maintain consistency. Either avoid variables or always use variables until it proves necessary to be different. Choosing one or the other randomly is not good. If you maintain consistency this by itself already helps communicate the intent of the code.
If people think more about the intent of the code and look for simplicity first of all they will end up having more quality and consequently more productivity in the long run.