Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » God classes in JDT
God classes in JDT [message #842895] Thu, 12 April 2012 18:10 Go to next message
Zhongpeng Lin is currently offline Zhongpeng LinFriend
Messages: 4
Registered: April 2012
Junior Member
Not sure if this is the right place to ask the questions, give me a pointer if it is not.

I am a PhD student doing research on the evolution of large source code files. I found there are two classes in JDT with more than 10 KLOC:

codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java

My questions are:

Do developers of JDT think these classes need refactoring? if yes, is there a plan to do that? if not, why?

Re: God classes in JDT [message #842907 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
I found there are two classes in JDT with more than 10 KLOC:

codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:

compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842909 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10

I found there are two classes in JDT with more than 10 KLOC:

codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:

compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842927 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842928 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842941 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842942 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842955 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842956 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842972 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842973 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842987 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #842988 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843007 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843008 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843031 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843032 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843056 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843057 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843089 is a reply to message #842895] Thu, 12 April 2012 18:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #843090 is a reply to message #842895] Thu, 12 April 2012 18:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
> I found there are two classes in JDT with more than 10 KLOC:
>
> codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:
> compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan
Re: God classes in JDT [message #845089 is a reply to message #842907] Sat, 14 April 2012 18:37 Go to previous messageGo to next message
Zhongpeng Lin is currently offline Zhongpeng LinFriend
Messages: 4
Registered: April 2012
Junior Member
Thanks Stephan for the reply. That gave much insight into these two classes.

Looking into the method lists for both classes as an outsider, I found many methods in each class share common prefixes, which are all verbs; they are only different in the object they process. Example in org.eclipse.jdt.internal.codeassist.CompletionEngine:

private int computeRelevanceForAnnotation()
private int computeRelevanceForAnnotationTarget(TypeBinding typeBinding)
private int computeRelevanceForClass()
private int computeRelevanceForEnum()
private int computeRelevanceForEnumConstant(TypeBinding proposalType)


Also, the consumeXXX methods in org.eclipse.jdt.internal.compiler.parser.Parser is another example. At the same time, switch statement is used to call different methods based on different object type (e.g. org.eclipse.jdt.internal.compiler.parser.Parser.consumeRule). These situations seem to show opportunities to take advantage of polymorphism, as suggested by Martin Fowler in his book Refactoring: Improving the Design of Existing Code. By using polymorphism, different processing logic will be encapsulated in different objects/classes, and the size of these two classes will be reduced. This should work at least "in theory", and I believe developers in JDT are aware of this, but I am interested in what difficulty prevented them from doing such a refactoring.

Any more insights? Thanks again!

Stephan Herrmann wrote on Thu, 12 April 2012 14:20
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
I found there are two classes in JDT with more than 10 KLOC:

codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.

I shyly suggested refactoring that class, which stalled probably because also an appropriate refactoring would be quite a challenge at this point. It would have been easier to split this way earlier in the development, I guess.

Quote:

compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java


For this class the huge size is quite natural: a long method (consumeRule) is generated by the parser generator (jikespg) and all methods called from there must be found in the same class. Size isn't causing much harm here, since methods are quite uniform, so complexity isn't too high, actually.

HTH,
Stephan

[Updated on: Sat, 14 April 2012 18:39]

Report message to a moderator

Re: God classes in JDT [message #845108 is a reply to message #845089] Sat, 14 April 2012 19:06 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Zhongpeng Lin wrote on Sat, 14 April 2012 20:37
Thanks Stephan for the reply.

... and sorry for the many dupes. I'm not sure if it was my browser or the forum software that ran berserk. Hope it won't happen again. Confused

Quote:

Looking into the method lists for both classes as an outsider, I found many methods in each class share common prefixes, which are all verbs; they are only different in the object they process. Example in org.eclipse.jdt.internal.codeassist.CompletionEngine:

private int computeRelevanceForAnnotation()
private int computeRelevanceForAnnotationTarget(TypeBinding typeBinding)
private int computeRelevanceForClass()
private int computeRelevanceForEnum()
private int computeRelevanceForEnumConstant(TypeBinding proposalType)


Also, the consumeXXX methods in org.eclipse.jdt.internal.compiler.parser.Parser is another example. At the same time, switch statement is used to call different methods based on different object type (e.g. org.eclipse.jdt.internal.compiler.parser.Parser.consumeRule).


As mentioned the Parser case is constrained by the interaction with the parser generator, so I'll focus on CompletionEngine in this reply.

Quote:
These situations seem to show opportunities to take advantage of polymorphism, as suggested by Martin Fowler in his book Refactoring: Improving the Design of Existing Code. By using polymorphism, different processing logic will be encapsulated in different objects/classes, and the size of these two classes will be reduced. This should work at least "in theory",

There is no difference between theory and practice, at least in theory Smile

Quote:
and I believe developers in JDT are aware of this, but I am interested in what difficulty prevented them from doing such a refactoring.

Any more insights? Thanks again!

When I last looked at possibilities to split CompletionEngine into several classes there was one particular question that made me scratch my head: how should we handle fields?
- easiest way would be to leave all state in the current class and let extracted classes access those fields externally (by way of one back reference to the CompletionEngine instance).
- could fields be meaningfully grouped so that also some fields could be extracted?
Ergo: when addressing the God Class smell we should also have a good answer to the God Object smell (i.e., not only the class but also its instances are large).

Next we would need a call graph of all methods to find an meaningful ordering to avoid cyclical call structures where extracted objects would call back into the "master" object etc. because a control flow that busily jumps back and forth between objects may actually be much harder to understand than the current implementation.

Both issues are of course addressable, but I hope this illustrates why I felt this would require a considerable chunk of time to find a separation that not only works but actually improves understandability and thus maintainability.

Additionally: any such refactoring would essentially render the version history of that file useless: for any particular line of code after the refactoring it will be pretty difficult to see "through" the refactoring to find when that line was introduced / last changed.

Ergo: practice shows that the difference between theory and practice is much larger than you ever dreamt of Smile

best,
Stephan

Re: God classes in JDT [message #846905 is a reply to message #845108] Mon, 16 April 2012 21:31 Go to previous messageGo to next message
Zhongpeng Lin is currently offline Zhongpeng LinFriend
Messages: 4
Registered: April 2012
Junior Member
Thanks Stephan for the insightful comments, they are very helpful to me as well. I will think about them when dealing with large files.
Re: God classes in JDT [message #873366 is a reply to message #842907] Fri, 18 May 2012 04:19 Go to previous message
Zhongpeng Lin is currently offline Zhongpeng LinFriend
Messages: 4
Registered: April 2012
Junior Member
Stephan Herrmann wrote on Thu, 12 April 2012 14:20
Zhongpeng Lin wrote on Thu, 12 April 2012 20:10
I found there are two classes in JDT with more than 10 KLOC:

codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java


This class indeed causes some pain every now and then. For regular JDT/Core development it is manageable, but I also maintain a fork of the JDT/Core (for Object Teams) and there merging changes into this class did cause significant grief in the past.


Hello Stephan,

Could you give more details about what pain CompletionEngine has caused to the maintenance of the project?

Thanks!

[Updated on: Fri, 18 May 2012 04:20]

Report message to a moderator

Previous Topic:eclipse project type
Next Topic:problem seeing watch expression value when debugging
Goto Forum:
  


Current Time: Fri Apr 26 11:59:34 GMT 2024

Powered by FUDForum. Page generated in 0.05097 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top