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
 Feature Requests
 Extract as Constant
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AGPX
Senior Member

28 Posts

Posted - Aug 26 2007 :  10:26:27 AM  Show Profile  Reply with Quote
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..

Edited by - AGPX on Aug 26 2007 10:27:11 AM

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Aug 27 2007 :  06:13:42 AM  Show Profile  Reply with Quote
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.
Go to Top of Page

AGPX
Senior Member

28 Posts

Posted - Aug 27 2007 :  08:35:47 AM  Show Profile  Reply with Quote
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.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Aug 27 2007 :  11:12:15 AM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

AGPX
Senior Member

28 Posts

Posted - Aug 28 2007 :  02:15:55 AM  Show Profile  Reply with Quote
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
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Aug 28 2007 :  08:21:04 AM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

AGPX
Senior Member

28 Posts

Posted - Aug 28 2007 :  08:51:52 AM  Show Profile  Reply with Quote
I get it now , i didn't understand you well . OK
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Nov 07 2014 :  10:07:55 AM  Show Profile  Reply with Quote
case=1492 is implemented in build 2052
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