Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Extract method refactoring could be smarter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

TomatoUser
New Member

USA
8 Posts

Posted - Nov 29 2011 :  10:13:13 PM  Show Profile  Reply with Quote
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  Show Profile  Reply with Quote
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)

Go to Top of Page

TomatoUser
New Member

USA
8 Posts

Posted - Dec 01 2011 :  6:02:35 PM  Show Profile  Reply with Quote
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.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Dec 02 2011 :  6:44:27 PM  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000