Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Extract as Constant

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
AGPX Posted - Aug 26 2007 : 10:26:27 AM
Hi,

We're using VAX in a project and it's a god damn cool tool.

During development we need some extra features VAX don't have such as Extracting a symbol as a constant.

I see currently some other assistance tools do this.I think it'll be a gem to VAX.

Thanks..
7   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Nov 07 2014 : 10:07:55 AM
case=1492 is implemented in build 2052
AGPX Posted - Aug 28 2007 : 08:51:52 AM
I get it now , i didn't understand you well . OK
feline Posted - Aug 28 2007 : 08:21:04 AM
I don't understand.

My suggestion, and the refactoring idea when implemented, are designed to take some code like this:

static void functionToUpdate()
{
    func1(bla(34), 7);
    // more stuff
    func2(4, bla(34));
}

which then becomes:

static void functionToUpdate()
{
    int new_variable = bla(34);

    func1(new_variable, 7);
    // more stuff
    func2(4, new_variable);
}

you then just need to convert "new_variable" into a constant. This is a two step process, but quite often people will want to extract a variable without turning it into a constant.
AGPX Posted - Aug 28 2007 : 02:15:55 AM
Yes , that works most of the time,but if constant is not defined as variable and you have lots of different kind of constants ,it gets harders to extract as constants
feline Posted - Aug 27 2007 : 11:12:15 AM
We are considering a similar feature, to turn a number or string into a local variable:

case=1492

once you have the variable it is a small step to make it a constant.

For how, if you are looking at a single function, or within a selection have you considered find and replace? Not quite the same, and it does leave you needing to add the constant by hand, but it should work most of the time.
AGPX Posted - Aug 27 2007 : 08:35:47 AM
Yes , you are right,i've never mention doing it in cross project. But at least including it as you explained or with a simpler way will be better than nothing.

Maybe it should be done by locally finding related references.Cross-project is not necessary and as you say it's not wise.As simpliest solution it can replace related symbol with only current selection.

It's a common refactoring used in many languages and IDE's.So that should be very good.
sl@sh Posted - Aug 27 2007 : 06:13:42 AM
IIRC this already was suggested. The problem with this is VAs ability to determine what is a constant and what not. E. g. if you have a considerably short string constant or an integer value, chances are that any automated replacement also replaces instances that shouldn't be!

What is worse, depending on the number of projects and their relative visibility, you might end up replacing constants in projects that do not know of the constant's declaration!

To make this kind of refactoring work in a useful way, it should prompt the user the same way the 'Rename' dialog does - enabling the user to select or unselect whatever needs to be replaced. Even then, I'm not sure it would be wise to have this work cross-project.

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