Eclipse Shortcuts and Key Bindings

To be really fast with an IDE developers need to be able to use the common IDE functions without the mouse. The functions used most often must be accessible with the keyboard only. Jesper Kamstrup Linnet has created a list of the Eclipse default key bindings. The default key bindings can be configured in Windows->Preferences->Workbench->Keys.

JUnit speaks

Sebastian Sanitz developed an Eclipse plugin which gives JUnit a voice – e.g. the voice of Homer Simpson. The plugin can be downloaded here.

The plugin needs Eclipse 3.0M8 and JDK 1.4.2.

Do You Speak Java?

Here is a code snippet I found somewhere. Can you figure out what it does? Try code reading first and if that doesn’t work, write a unit test. Is there a way to refactor the code to be more readable without loosing performance?

public int doSomething ( final int v[] ) {
int i = 0, j = v.length - 1;
for ( ; !( v[i] >= v[j--] && i++ == ++j ); );
return v[j];


Projects using EJB have a common problem: EJBs are necessary for some reason (e.g. scalability) but using EJBs does harm the development process and the flexibility of the application:

  • The turn-around times (edit-compile-deploy-execute) are much longer with an application server than within a stand alone rich client application.

  • If unit tests fail, there are two possible reasons: The code is broken or the application server is not available. It can cost some efforts to figure out what the reason really was.

  • Some application servers consume a lot of memory and are therefore not usable on developer PCs. Then parallel tests of developers may influence each other in an unintended way.

  • Sometimes there is the requirement that the same application must be runnable with and without an application server. That’s especially true for off-the-shelf products.

These problems are solvable through architecture. It is possible to introduce abstractions that allow to execute the application with and without an application server. On the downside these abstractions introduce a lot of complexity which often irritate developers.

With MockEJB there is the alternative to solve the mentioned problems with technology. MockEJB provides a local container for session beans (entity beans are not supported yet). That enables the application to simply use EJBs without further abstractions while being executable without an application server.

Names in source code are important

Nearly everybody would agree that giving communicating names to packages, classes, methods and fields is important. But when non-communicating names are in place developers often argue that naming is not that much important. The pragmatic programmers Andrew Hunt and David Thomas have a strong argument for the importance of naming on their web site (stroop effect).

SWT vs. Swing: API

Today two major and incompatible UI libraries are available for Java developers: SUN’s Swing and IBM’s SWT (which is used for the Eclipse platform). Often it is claimed that SWT is the faster and more stable solution. Since in our projects Swing was fast and stable enough a point of major interest was the API: What is easier and more flexible to program. I did a little experiment based on the very good SWT tutorial „Using the Eclipse GUI outside the Eclipse Workbench, Part 1: Using JFace and SWT in stand-alone mode“ from Adrian Van Emmenis. I took the SWT file explorer consisting mainly of a tree and a table from the tutorial and programmed an equivalent Swing file explorer. The code can be downloaded for the SWT-File-Explorer and the Swing-File-Explorer.
The main differences between the two explorers:

  • The Swing explorer needs with 249 LOC about 30% more lines of code than the SWT explorer with 192 LOC.
  • Setting the properties of SWT widgets is follows the C style with expressions like SWT.HORIZONTAL SWT.NULL. Since the properties are simply integers there is a (small) lack of type safety.

One (subjective) word about performance: When using the two explorers I can hardly notice any difference. Only when directories contain very many files the SWT explorer seems to be a bit faster.