Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

C Refactorings
Hi I'm currently a student working on an honours-level project to
create a visual tool which will be able to represent C project files
and code as well as allow the user to perform high and certain low-
level refactorings.

At the moment I'm compiling a list of refactorings which are
applicable to C that people who program alot with structured
programming languages may find useful.

So far I've got (some I got from someone else's post on another google
group):

- Rename variable/function
- Move variable/function
- Reduce scope of variable
- Publish function (make it public, put a declaration in the .h file)
- Perish function (make it static, remove it from the .h file)
- Add/Remove parameter from function
- Reorder function arguments
- Remove unnecessary includes

Cheers!

Report this thread to moderator Post Follow-up to this message
Old Post
pingu219
03-27-08 09:46 AM


Re: C Refactorings
pingu219 wrote:

> Hi I'm currently a student working on an honours-level project to
> create a visual tool which will be able to represent C project files
> and code as well as allow the user to perform high and certain low-
> level refactorings.

You might soon discover why nobody generally tries to do this.

> At the moment I'm compiling a list of refactorings which are
> applicable to C that people who program alot with structured
> programming languages may find useful.

C is (should be!) only used in super-high performance situations. The langua
ge
constantly risks undefined behavior, exchanging slow development time for fa
st
executable time and small footprint.

An ordinary refactoring tool depends on soft code where any compilable
expression is a legal expression. Casually speaking, a refactor preserves
testable behaviors, such that your tests will pass both before, during, and
after the operation. A C refactoring tool would have the incomprehensible bu
rden
of preserving all kinds of untestable behavior, without creating undefined
behaviors.

> - Rename variable/function
> - Move variable/function
> - Reduce scope of variable
> - Publish function (make it public, put a declaration in the .h file)
> - Perish function (make it static, remove it from the .h file)
> - Add/Remove parameter from function
> - Reorder function arguments
> - Remove unnecessary includes

Get with John Lakos's work with large scale C++ software design, including a
ny
drafts for a new book I heard he's working on.

And you should start with the Refactoring book for your list. You seem to be
missing the most important ones - the Extracts. Extract Local Variable, Extr
act
Method, and Extract Class are the heart of emergent design. Yet a true Extra
ct
should find _each_ call site for its extractee, and introduce a call there. 
That
would be extremely hard in C - under macro abuse and such - so I think that'
s
why they are not on your list.

--
Phlip

Report this thread to moderator Post Follow-up to this message
Old Post
Phlip
03-28-08 03:12 AM


Re: C Refactorings
> That would be extremely hard in C - under macro abuse and such - so I
> think that's why they are not on your list.

Yeah, macro abuse is the usual reason given for the lack of
refactoring tools for C.

I suspect the real reason is more that C programmers don't want
refactoring tools as much as for some languages.  Sure, macros are a
problem, but most refactoring tools don't try to be perfect, so I
start with the easy cases.

After all, languages like Ruby have at least as many challenges for
refactoring tools (not the same challenges as C, however), but the
refactoring tools exist.

Report this thread to moderator Post Follow-up to this message
Old Post
Jim Kingdon
03-28-08 03:12 AM


Re: C Refactorings
Jim Kingdon wrote:
 
>
> Yeah, macro abuse is the usual reason given for the lack of
> refactoring tools for C.

If that were the end of it...

int x[42][2];
memset(x, 0, sizeof x);
x[0][13] = 1;

C exists to permit abuses like those. It is portable assembler. You code to
a virtual machine, with enforced standards such as "contiguous arrays".

--
Phlip



Report this thread to moderator Post Follow-up to this message
Old Post
Phlip
03-29-08 12:13 AM


Re: C Refactorings
Thanks for the replies

The reason my list of refactorings was limited is because I will
mostly only be featuring refactorings which don't take place within a
function, as it would be abit difficult to integrate the internals of
a function visually for display and manipulation with my graphical
tool. Only problem is now my list of refactorings seems -too- limited.

Report this thread to moderator Post Follow-up to this message
Old Post
pingu219
04-02-08 12:11 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Extreme Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:20 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.