Thread overview
Re: Mainstream D Programming
Oct 15, 2007
Jussi Jumppanen
Oct 15, 2007
Bill Baxter
Oct 15, 2007
BCS
Oct 15, 2007
Jussi Jumppanen
Oct 15, 2007
Walter Bright
Oct 15, 2007
Bill Baxter
Oct 15, 2007
Walter Bright
Oct 15, 2007
Alexander Panek
October 15, 2007
Ary Manzana Wrote:

> Does nobody refactor their code?

I do have to admit the refactoring rename feature found in the MS Visual Studio IDE is very nice, but I'm not going to change my text editor just for one feature.

> If so, how a text editor helps?

Refactoring is still possible in a text editor:

 Syep 1) Run a grep to find all the instances of text
 Syep 2) Load up all the files found
 Syep 3) Change each name one at a time or all in one hit
 Syep 4) Run a build to check your changes

This might take an extra minute or two, but it's still pretty easy todo.

October 15, 2007
Jussi Jumppanen wrote:
> Ary Manzana Wrote:
> 
>> Does nobody refactor their code? 
> 
> I do have to admit the refactoring rename feature found in the MS Visual Studio IDE is very nice, but I'm not going to change my text editor just for one feature.
> 
>> If so, how a text editor helps?
> 
> Refactoring is still possible in a text editor:
> 
>  Syep 1) Run a grep to find all the instances of text
>  Syep 2) Load up all the files found  Syep 3) Change each name one at a time or all in one hit
>  Syep 4) Run a build to check your changes
> 
> This might take an extra minute or two, but it's still pretty easy todo.

Where grep doesn't work so well is when you want to rename a variable called 's' to something else.  Or a better example is changing the name of a member of one class only.  Say we want to change the "name" member of one class.   That's likely to have a lot of false hits that grep, without any semantic knowledge, won't be able to help you with.  A good refactoring IDE can (I think!) distinguish between things called 'name' that are referring to the member of the class in question and those that aren't.

--bb
October 15, 2007
Reply to Bill,

> Jussi Jumppanen wrote:
> 
>> Ary Manzana Wrote:
>> 
>>> Does nobody refactor their code?
>>> 
>> I do have to admit the refactoring rename feature found in the MS
>> Visual Studio IDE is very nice, but I'm not going to change my text
>> editor just for one feature.
>> 
>>> If so, how a text editor helps?
>>> 
>> Refactoring is still possible in a text editor:
>> 
>> Syep 1) Run a grep to find all the instances of text
>> Syep 2) Load up all the files found
>> Syep 3) Change each name one at a time or all in one hit
>> Syep 4) Run a build to check your changes
>> This might take an extra minute or two, but it's still pretty easy
>> todo.
>> 
> Where grep doesn't work so well is when you want to rename a variable
> called 's' to something else.  Or a better example is changing the
> name of a member of one class only.  Say we want to change the "name"
> member of one class.   That's likely to have a lot of false hits that
> grep, without any semantic knowledge, won't be able to help you with.
> A good refactoring IDE can (I think!) distinguish between things
> called 'name' that are referring to the member of the class in
> question and those that aren't.
> 
> --bb
> 

how about a Refactoring primitives tool set:

tool1: runs like DMD but dumps the name of the symbol at a given location

tool2: same as tool1 but in reverse, lists the location of every reference to symbol "____"

a few more tools along this line (and a lib of the code behind them) and you could whip out a lot of refactoring stuff really quick


October 15, 2007
Bill Baxter Wrote:

> A good refactoring IDE can (I think!) distinguish between things called 'name' that are referring to the member of the class in question and those that aren't.

The MS Visual Studio name refactoring feature does exactly that.

October 15, 2007
Bill Baxter wrote:
> Where grep doesn't work so well is when you want to rename a variable called 's' to something else.

That'll teach anyone not to use single letter names for non-locals <g>.
October 15, 2007
Walter Bright wrote:
> Bill Baxter wrote:
>> Where grep doesn't work so well is when you want to rename a variable called 's' to something else.
> 
> That'll teach anyone not to use single letter names for non-locals <g>.

But the same scenario is true of local variables too.
A refactoring tool can help you rename every 's' within a function without messing up other symbols that just happen to contain that letter.

--bb
October 15, 2007
Bill Baxter wrote:
> Walter Bright wrote:
>> Bill Baxter wrote:
>>> Where grep doesn't work so well is when you want to rename a variable called 's' to something else.
>>
>> That'll teach anyone not to use single letter names for non-locals <g>.
> 
> But the same scenario is true of local variables too.
> A refactoring tool can help you rename every 's' within a function without messing up other symbols that just happen to contain that letter.

True, that'd be nice, but it isn't compelling by itself. With the other features Robert mentioned, the aggregate becomes compelling.
October 15, 2007
On Mon, 15 Oct 2007 18:30:18 +0900
Bill Baxter <dnewsgroup@billbaxter.com> wrote:
> But the same scenario is true of local variables too.
> A refactoring tool can help you rename every 's' within a function
> without messing up other symbols that just happen to contain that
> letter.

How great, that my text editor can work with regex on ranges. :)

-- 
Alexander Panek <alexander.panek@brainsware.org>