Topic: Local variables - angrily? Whether rights Fowler?
Faced here interesting judgement. Sent a piece of changes on to other command and received from them such : Local variables are not good to have in code. You can check what Martin Fowler Says on this https://refactoring.com/catalog/replace Query.html http://blog.boyet.com/blog/blog/local-v rritating/ Change which I there made, simple enough and directly to does not concern. Simply something that I corrected, while understood with their code. Was: AzureVnet azureVnet = azureVnetCacheFactory.getVnetCache (azureGatewayDeployParams.getTargetVnetId ()); Became: String targetVnetId = azureGatewayDeployParams.getTargetVnetId (); AzureVnet azureVnet = azureVnetCacheFactory.getVnetCache (targetVnetId); And here their comment very much puzzled me. Especially that not people refer to the preferences, and on Martin Fowler's recommendations. At them there in that part of the code it is a lot of noodles and I thought that people simply do not have experience to write more clear code and me it is necessary to work with them, to show examples and all goes normally. But now at me the impression is added that they consider the code to normal and appropriate best recommendations. I, truth, yet did not ask them about methods in 250 code lines and a heap save-paste, but already I suspect that they are convinced of faultlessness of the approach. I more than once faced that that command accepts a defensive position on any sentences on improving of their code. And what you think of Fowler's that recommendation? To what it generally? How in your opinion, what is more readable - local variable or a sixfold call of the necessary method in those places where this value is necessary? You code style guidelines somehow regulate it? I consider that local variables are in most cases more readable. Without fanaticism, it is finite - if somewhere it was thrust "" it not terribly if "" it is necessary - to enter already better two or more times a variable. Results of all other methods, not "" - almost unambiguously go to local variable. In this plan I like the recommendation which was applied in those commands in Microsoft in which I worked: "one sink - one action". I somehow will consider this recommendation in a separate subject, and here now it would be desirable to hear judgement of colleagues on local variables. That I understood at Fowler - he unambiguously names harm local (changeable) variables and here I with it agree, though and for other reasons. But also invariable local variables he also names undesirable. The cores of argument at Fowler two - in his opinion, it complicates refactoring with selection of a new method (extract method) and local variables worsen . But I in an emphasis do not see any problems with refactoring (at invariable local variables) and in the plan I hold opposite judgement - on me, a heap and set of nested calls are much less readable, than concrete local variables.