Re: What Refactorings Would you Like for C



pingu219 wrote:

Thanks for the replies all.

At the moment I'm kind of limiting the refactorings I consider as my aim
is to allow such refactorings to be able to be done via a click, drag and
drop...etc visual interface without the user actually delving into the
code itself. That's the reason why my initial list seemed somewhat small.

When I code, I keep my fingers on the keyboard, mousing as little as
possible. I alternate between editing source and hitting a test button. When
I want to refactor, I drag-select some code, then my "muscle memory"
performs one of your refactors! So it seems to me that your most important
UI goal would be simple keystrokes that do these refactors.

Next, programmers generally should not refactor by looking at a diagram of
code (in a UML tools), and then dragging all its boxes and lines around, all
at the same time. Software engineering provides many, many reasons for
refactoring to be incremental, and mixed in with other activities.

The least reason is that without a perfect refactor tool, I don't know which
refactor might cause a bug. So - even if the entire object model deserves to
be moved around - if I move it one small change at a time, and run all my
tests, I have better odds that a test failure will show why the refactor was
wrong.

And, as I analyzed before, under C your refactor tool cannot be "perfect".
It will always risk changing behavior, because C is so persnickety!

Currently though, I'm looking for a good C parser which I can use.

Use the code browsing information that your compiler emits. gcc has such a
system - editors like Emacs use it for command-completion.

Because refactoring works best within the editing and testing cycle, you
should use the exact information the compiler just saw during its last test
run. Because the compiler is already incremental, and because its
information exactly matches the mix of conditional compilations, macros, and
other C side-effects, you would add a lot of risk to your parsings if you
don't match exactly what your compiler did.

--
Phlip


.


Quantcast