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
 Create local variable from usage location
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MikMik
Senior Member

42 Posts

Posted - Oct 06 2021 :  07:16:53 AM  Show Profile  Reply with Quote
Is there a way to control where Create From Usage places the declaration of a local variable?
I would expect/like it (in C++) to create it as close as possible as the usage, not at the beginning of the enclosing function. At least, it should be in the same code block where the usage is, to conform with most modern coding standards.


int Baz()
{
  //myvar is created here
  

  if (Foo()) {

    // It should be created here
    
    int b = Bar (myvar);
  }
  return 0;
}


In this small example it is quite straightforward to place it correctly afterwards, but with lengthy functions (I know, I know...), I have to go search for the declaration and move it to its correct place...
Maybe I'm missing some configuration...

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Oct 06 2021 :  09:45:42 AM  Show Profile  Reply with Quote
That makes sense and is a reasonable request. I have put in a feature request for this to see what our developers make of this:

case=146285

As for long functions, you might find the Extract Method command helps:

https://docs.wholetomato.com/default.asp?W288

but changing large methods into smaller methods will take time, no instant fixes here. And occasionally you do just need a large method.

zen is the art of being at one with the two'ness
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