Getting rid of writting C++ boilerplate code

Andreas Pakulat apaku at gmx.de
Mon Jul 3 20:26:23 BST 2006


On 30.06.06 20:38:33, Frank Sonntag wrote:
> one annoying "feature" of C++ is that you have to duplicate code, when you 
> separate definition from declaration.
> I think it would be nice if kdevelop could help here by automatically adding 
> code.
> Let's say you add a new function declaration to a class. The plug-in would 
> then add an empty definition to the definition file.

This is already working, though not by "typing" the method, but by using
the Ui. Right-click on a class in the class browser and activate "add
method".

> It would also be nice if later the code would be kept in sync, so that you 
> never have to do a change twice.
> 
> Does that sound feasible (and sensible)?

This is normally called refactoring and shouldn't be restricted to
method names. It should also work on classes and even files (i.e. moving
a file around in a project updates all include's and possibly
build-system-files). Also there are quite some more things that are
part of refactoring (for example extracting code out of a method into a
new method and placing a call into the old one).

> If nobody is already working on such a plug-in, I would be interested to do it 
> myself and would appreciate any suggestions as to what existing code might 
> helpful (e.g. because it keeps track of symbols or the like).

2 notes here: I don't think this is possible in kdevelop3 and IIRC it is
a planned feature for kdevelop4. Also there won't be an official such
feature in time for the last kdevelop3 release, so you should look into
kdevelop4 anyway.

Also it sounds from your description as you want this to work while
typing, I don't think that is a good idea because it potentially slows
down typing. I think a keyboard shortcut for both, that takes the
current position in the file as context is better, i.e. activating
rename when beiing somewhere at a method opens up a dialog to rename
that method...

Andreas

-- 
Are you ever going to do the dishes?  Or will you change your major to biology?




More information about the KDevelop mailing list