Saturday, June 21, 2008

toString() generator will be in a separate dialog

Last week I did some work to make my code clean enough to post on Bugzilla. When I submitted it, Martin suggested that it's not a good idea to have toString() generator in the same dialog with hashCode()/equals(). I was surprised at first, as he was the first person to tell me so. But his arguments were strong: the dialog is too big and there's no good name for the action. His main argument was that hashCode/equals doesn't usually use the same fields as toString. I had doubts about it but I don't have enough experience to argue.
I've made a quick poll about it on the eclipse IRC channel - 100% of participants said that toString generation should not be combined with hashCode/equals (100% of 1 person - I guess IRC is not a good place for polls :P)
I tried to fit elements on the dialog to make it look better, but without satisfactory results (see here and here). So I decided to make a separate action and I won't get back to the previous idea unless there's *a lot* of people asking for it. I submitted a patch with the new action today and I'm waiting for feedback. If you're too lazy to check the patch, here's a screenshot of prepared dialog:

Plan for the next week: investigate possible ways of template handling. I know there's a rich template support in Eclipse but I'm afraid it may not be exactly what I need as these templates relate to the code directly. I saw a nice dialog with templates in Mylyn plugin (Preferences->Mylyn->Team) and I'm going to see how it's done. Do you have any suggestions of where else I should look?

Sunday, June 08, 2008

First steps...

It's the end of the semester here and I must work hard on my grades therefore I can't spend much time on my GSOC project (this situation will last until the last week of june). I managed to do some work this weekend though and here are the results:

1. I created a simple toString() generator to see if it will work. And it does :) For now it's only a string concatenationi with hardcoded format. I don't know how to put line breaks in generated code and I have no idea where to look for it. Any clues?

2. I decided to start with something simple - redesign hashcode/equals generation dialog to include toString() features. Here's the effect:

"Up" and "Down" buttons already work - I copied this functionality from "generate constructor using fields" dialog. The rest of the controls don't have any effect yet..
I plan to add a list of class methods to the view (in a separate node of the tree). With all methods on the list, the option to use getters instead of fields accessors is no longer needed (unless we want this option for hashCode and equals, but that's another story).

That's all for now, I know it's not much. But I think I can complete the project without many problems if I focus all of my attention on it next month.

BTW, Mike, should I put my code somewhere for everybody to see? Right now I modify my local copy of org.eclipse.jdt.ui plugin - is that ok?