Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Refactoring of AST and Parser code to improve support for Refactoring etc.

Hi Peter,

I'm just wondering if anyone in your group is currently working on these
refactorings. In particular I'm interested in implementing refactoring 1)
that you describe. I'm working with a lot of code that builds ASTs and I
think the code could be made a lot shorter if it was possible to pass child
nodes to the constructor methods rather than use several setters.

I could not find an open bug for this, so I opened bug #206952


Mike Kucera
Software Developer
IBM CDT Team, Toronto
mkucera@xxxxxxxxxx



                                                                       
             Peter Sommerlad                                           
             <peter.sommerlad@                                         
             hsr.ch>                                                    To
             Sent by:                  <cdt-dev@xxxxxxxxxxx>           
             cdt-dev-bounces@e                                          cc
             clipse.org                Hi Peter,                       
                                                                       
                                       I'm just wondering if anyone in 
             09/17/2007 02:56          your group is currently working on
             AM                        these refactorings. In particular
                                       I'm interested in implementing  
                                       refactoring 1) that you describe.
             Please respond to         I'm working with a lot of code that
               "CDT General            builds ASTs and I think the code
             developers list."         could be made a lot shorter if it
             <cdt-dev@eclipse.         was possible to pass child nodes to
                   org>                the constructor methods rather than
                                       use several setters.            
                                                                       
                                       I could not find an open bug for
                                       this, so I opened bug #206952   
                                       Wuyts Roel <wuytsr@xxxxxxx>, Mirko
                                       Stocker <me@xxxxxxxx>, Guido    
                                       Zgraggen <g1zgragg@xxxxxx>,     
                                       Emanuel@xxxxxxxxxxx, Thomas Corbat
                                       <tcorbat@xxxxxx>, Lukas Felber  
                                       <lfelber@xxxxxx>, Doug Schaefer 
                                       <DSchaefer@xxxxxxx>             
                                                                   Subject
                                       [cdt-dev] Refactoring of AST and
                                       Parser code to improve support for
                                       Refactoring etc.                
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       




Dear CDT developers,

I would like to suggest that you discuss the following during your
meeting this week:

My vision is to use CDT as a platform for tools that allow C++
developers to analyze and simplify their code. We (IFS institute for
sofwtare)
started already with simple Refactorings, but I believe there is need
for much more.

This implies that we want to rely on CDT's AST and parser code for
our plug-ins. For better relation to the original source, we must
augment the AST and the parser to support "virtual preprocessing",
keeping track of both the "real" C++ as well as the original source
code. Our first addition to allow for keeping track of comments is a
first step but we are not yet able work with it like a breeze.

As a teacher of Refactoring and a frequent code reviewer I see many
potential improvements for the java code and design of CDT's AST and
parser. I asked Doug Schaefer if companies using CDT for their
products  rely heavily on the AST and parser functionality. He told
me that this is not used directly and refactoring this part shouldn't
hurt (much).

The following examples show you areas where we see heavy improvement
possible:
1) Almost all AST object creation methods and the AST
classes' constructors don't use parameters. So at each place where
such an object is constructed, additional calls to setters need to be
made to initialize the object correctly. This is error prone and
leads to code duplication.
2) Another area is a lot of copy-pasted code in the application of the
Visitor design pattern.
3) A third area that looks "smelly" from a Java 5 perspective is the
heavy use of Java arrays as almost the only collection data structure
used. Today, we would be able to use appropriate ArrayList<T> or
SortedSet<T> or others for efficient extension and set operations,
depending on context. This can improve readability of the code and
reduce potential for mistakes in the hand-coded loops.

It would be great if we (IFS) would get the possibility to simplify and
refactor the code of the AST and parser and may be also surrounding
code areas (not a rewrite). This would allow (hopefully) to provide
better unit testing for that code as well and will help us to augment
it with information we need for our refactoring and other tools. A
switch to java 1.5 as the official platform language for CDT could be
used as an "excuse" to do so. It might also give the chance to
improve indexing further (only a guess).

I know, every contributor to CDT did his/her very best and as an
outsider without some of the constraints you all have, it is much
easier to criticize.

We already invested (public and self-earned money) heavily into C++
Refactoring and want to become it a feature that is really useful.
Any sponsoring of our work is appreciated :-)

Tell me, what you think about it and let us Refactor the smelly code,
to make it clean and more usable and extendable in the future.

Cheers
Peter.

--
Prof. Peter Sommerlad

Institut für Software: Bessere Software - Einfach, Schneller!
HSR Hochschule für Technik Rapperswil
Oberseestr 10, Postfach 1475, CH-8640 Rapperswil

http://ifsoftware.ch
tel:+41 55 222 49 84 == mobile:+41 79 432 23 32
fax:+41 55 222 46 29 == mailto:peter.sommerlad@xxxxxx



_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




Back to the top