Author |
Topic |
|
TomatoUser
New Member
USA
8 Posts |
Posted - Nov 29 2011 : 10:13:13 PM
|
The extract method refactoring isn't as smart as I think it should be. Specifically, it tends to make variables as parameters that are only used within the code of the extraction and therefore should be automatically made local variables to the extracted method.
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Nov 30 2011 : 5:43:02 PM
|
Sensible suggestion! I have put in an enhancement request to see what the developers make of it:
case=63055
Just to double check did you mean the following case? (extremely simplified snippet)
|
|
|
TomatoUser
New Member
USA
8 Posts |
Posted - Dec 01 2011 : 6:02:35 PM
|
Basically. Though, after posting this, I did think of something. And that is, I've done a lot more Delphi (Pascal) over the last few years. In Pascal, the variable declarations have to be at the top, like old-style C. So, basically, the Pascal refactor engine knows where to look for the variable declaration and if the variable isn't used anywhere outside of the extraction, it moves the variable declaration. In C++, variables don't have to be declared at the top, and could include an initialization in the declaration. So, the equivalent C++ refactor engine, to do the same, would have to be a bit smarter. But presumably could be done. |
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Dec 02 2011 : 6:44:27 PM
|
Yes, indeed we have to be careful implementing this. e.g. initialization may use an other local variable that is used outside the selection... |
Edited by - accord on Dec 02 2011 6:45:09 PM |
|
|
|
Topic |
|