Re: Diamond back refactoring (again, I know...)
From: Gerrit Beuze (gerrit[at]modelmaker[dot]demon[dot]nl)
Date: 09/24/04
- Next message: Alessandro Federici: "Re: Java feature"
- Previous message: Derek Davidson: "Re: Java feature"
- In reply to: Jim Cooper: "Re: Diamond back refactoring (again, I know...)"
- Next in thread: Jim Cooper: "Re: Diamond back refactoring (again, I know...)"
- Reply: Jim Cooper: "Re: Diamond back refactoring (again, I know...)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 24 Sep 2004 11:42:13 +0200
> > Especially when writing libraries renaming in a non local scope is more
> > damaging than useful.
Fully agreed. But in some cases it's OK and intended.
> I'm sure I've missed your point here. Why is that so? The Rename
> refactoring only renames what it should. It's not the old search and
It cannot always do that: I have watched the last few weeks while
working on some code and found that you need both:
full context aware replace and limited to a certain scope only.
When implementing a new method I sometimes start with a copy of an existing method
and rework that as required. It's in these cases where you certainly do not want
a full rename: what if the new method should work on a different field, call different methods
but in the same "pattern"?
assume field FOriginal and method DoOriginal
procedure TSample.OriginalMethod;
begin
if Valid then
FOriginal := DoOriginal
else
FOriginal := 0;
end;
procedure TSample.CopiedMethod;
begin
if Valid then
FOriginal := DoOriginal
else
FOriginal := 0;
end;
The intend of this method is to do something SIMILAR, but not on the fields
FOriginal and method DoOriginal: instead it shoudl operate on FNew and DoNew
liek this:
procedure TSample.CopiedMethod;
begin
if Valid then
FNew := DoNew
else
FNew := 0;
end;
In this simple case it's easy to change by hand but in more complex cases
you'd want a Rename that's limited to Local Scope.
Invoking a find references and rename in CopiedMethod would
also affect the OriginalMethod and the original fields. Which is what you do not want.
That's why I use ModelMaker Code Explorer's "Rename local" refactoring
combined with the DB Rename refactoring.
In fact in the above example I would first use
RenameLocal FOriginal => FNew
then AddField (put cursor on FNew, press Ctrl+Alt+F)
then RenameLocal DoOriginal => DoNew
then AddMethod ((put cursor on DoNew, press Ctrl+Alt+M)
all available in Delphi 5-8 and DB with ModelMaker Code Explorer.
Gerrit Beuze
ModelMaker Tools
- Next message: Alessandro Federici: "Re: Java feature"
- Previous message: Derek Davidson: "Re: Java feature"
- In reply to: Jim Cooper: "Re: Diamond back refactoring (again, I know...)"
- Next in thread: Jim Cooper: "Re: Diamond back refactoring (again, I know...)"
- Reply: Jim Cooper: "Re: Diamond back refactoring (again, I know...)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]