Archive for March, 2008

More on the Java IDE comparison

Sunday, March 30th, 2008

Important: you can read the entire article, as it builds up, at this URL

Code template expansion

Template expansion is another time saving feature mainstrem java IDEs support nowadays. The feature consists in a setting up an abbreviation which when typed and followed by a specific key combination expands to a full featured piece of code. For example, you could set up psf+TRIGGER to expand to public static final. Or sout+TRIGGER to expand to System.out.println. Once you get used to this feature you become addicted. Templates are written in a simpe language, which can do more or less advanced things, depending on the implementation.

IDEA’s code template expansion feature is the most advanced, mainly because the template definition language takes advantege of the state of the art code querying mechanism that is built into this IDE. When defining templates in IDEA you can query variables of a certain type, or of certain types.

For example, the following template could expand into while (iterator.hasNext()) { Person person = (Person)iterator.next() } and the cursor will be placed where the END tag is.

while($ITER$.hasNext()){ $TYPE$ $VAR$ = $CAST$ $ITER$.next(); $END$ }

This is cool already, but it gets even better when you notice that you can ask IDEA to replace $ITER$ with variables of a certain type - in this case, Iterator. This can be done by specifying that $ITER$ is a variableOfType(”java.util.Iterator”). After doing so, when the code is expanded, IDEA will ask you to choose one of iterators in scope. You can also specify that $TYPE$ should take the value rightSideType(). This takes effect with typed collections in jdk 1.5 - at expansion time TYPE will automatically be replaced with the type of the elements contained in the collection. Regarding $VAR, you can ask IDEA to suggest a variable name, by setting it to suggestVariableName(). If you do so IDEA will propose you variable names based on the contained type. For example, if the type is ImageDescriptor IDEA will propose descriptor and imageDescriptor. All you have to do is choose the name you like most or type your own if your not happy with any of the default ones. Choosing one of the proposed choices, however, tends to result in very readable code.

It’s possible and very easy to write your own templates. I wrote one to help me initialize log4j loggers. This is the typical situation where template code expansion is very handy. Initializing a logger is an annoing, repetetive task which doesn’t have anything to do with the business logic you write. Here is a small template that helps you deal with the problem:

private static final Logger log = Logger.getLogger($CLASS_NAME$.class);

Then you insruct IDEA to give $CLASS_NAME$ the value className(), register your template under the logdecl abbreviation and you’re set. All you have to do from now on is type logdecl+TAB and that IDEA will declare that annoying logger for you.

Aparently Eclipse offers code template expansion too, but I haven’t been able to make it work. Just couldn’t find it. But apparently it’s there. But if I can’t find it it’s just like it wouldn’t be…. hmmm……

Netbeans offers code template expansion with almost the same features as IDEA - it’s slightly less flexible though. You can define your templates, define shortcuts - I have the feeling there are less options then in IDEA. On the other hand, I’ve not been able to change the activation key - which is SPACE, by default. Also, the activation sequence is kinda weird: the template is only expanded if you press SPACE just after the abbreviation. If you type the abbreviation move your cursor, then comme back and try to expand, it doesn’t work. Have to delete the last letter, retype it and quickly press SPACE . I haven’t been able to change the activation key - the config dialog let’s you change it, SPACE doesn’t work any more, but the new key doesn’t work either.

The winner here is IDEA again, with Netbeans comming in second and Eclipse third.

Getter / Setter / Constructor generation

Getter / setter / constructor generation features are comparable in IDEA and Eclipse. Both products offer quite complete features and there is nothing much to say on this matter. Netbeans has a slightly different approach on getter / setter generation: the feature is not available under the “source” menu, but under “refactoring”, and it’s called “encapsulate fields”. A little wierd - I wouldn’t think about this as refactoring - but hey, the feature is there. If I had some trouble finding the getter setter generation feature, I was totally unable to find an action to let me generate constructors. This is not a very good point for Netbeans, as constructor generation is a very widely used feature. The feature may be there but if I need more the 5 minutes to find it, it’s just like it’s missing. So the winners in this category are IDEA and Eclipse with similar and equally easy to use features with Netbeans comming in third, offering hard to find, not so easy to use functionality.

Open Source and Offshoring: Two Disruptive Forces Begin to Converge?

Friday, March 28th, 2008

I was reading an interesting blog note Open source meets off-shoring where Steve Hamm comments on the recent announcement by the database company Ingress to go offshore “I think this is a significant announcement. It will make other players take heed–both on the open source software side and within the Indian tech industry.” Tom Berquist, CFO for Ingress is equally upbeat about the trend in his blog stating how the “Two Disruptive Forces Begin to Converge” Tom says:When they work with our products they can get started immediately using the open source GPL license, without having to procure a commercial license. After they build and test the application (and fully understand the load characteristics) they can purchase database support subscriptions from us that tie directly to the number of servers they need to purchase. Nothing is wasted, and the software-related costs are deferred to the end of the project. This is a huge advantage to the customer and the services firm, and we believe that over the course of time all development will be done on open source technology even though some of the production deployment will continue to be done on commercial software.Satyam’s Sadagopan is naturally upbeat about the viewpoint. He blogs ‘I particularly like the way Tom has captured the rationale behind the rise of the offshore service firms.’Agreed that Open Source and Offshoring is a “potent combination” for businesses to pursue. However, I wonder what’s new in this announcement?
A few examples of how Infosys is managing and working on Open Source projects leveraging on the offshoring strengths:Supporting open source development communities in India: “Infosys Technologies Ltd. is happy to support the Free and Open Source community by becoming the Gold sponsor for Linux Bangalore/2004″. Research and publications: Wikipedia quotes how Infosys has contributed to various open source initiatives. “Computer scientists working at Infosys have contributed to the Mozilla community by inventing a new browsing concept called LiveURLs. Infosys has also worked with the Linux community in adding support for the EDB9312 (ep93xx based) development board developed by Cirrus Logic in the Linux kernel. This was later accepted by Linus Torvalds and incorporated into Linux.” On similar lines publications from Infosys researchers include the tutorial: Using Open Source for Enterprise SearchTOGAF: Infosys is an active member of

Hello world!

Friday, March 28th, 2008

Welcome to Merchantcow.com. This is your first post. Edit or delete it, then start blogging!