Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Create local variable from usage location

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
MikMik Posted - Oct 06 2021 : 07:16:53 AM
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...
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 06 2021 : 09:45:42 AM
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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000