Enter your email address:

Delivered by FeedBurner

May 2008

Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Tools

  • Google Referals

Eclipse

October 10, 2007

Protected variables cause subtle bugs - don't use them

This has been said before: Protected variables are evil. But apparently as I've been doing some debugging into the Eclipse code I'm reminded it needs saying again.

Let's suppose we write a base class

public class SimpleBase {
   protected Object value = new Integer(10);
   public printValue() {
      system.out.println(value.toString());
   }
}

public class Derived extends SimpleBase
{
   public Derived() {
     value = null;
   }
}
...
main() {
  new SimpleBase().printNumber();
  new Derived().printNumber();
}

Continue reading "Protected variables cause subtle bugs - don't use them" »

October 04, 2007

Don't call overridable methods in constructors

MS has a rule about this in FxCop. PMD has a rule:

ConstructorCallsOverridableMethod. In both cases the point is to discourage the following weird behaviour. From Eclipse:
public abstract class CellEditor {
    protected CellEditor(Composite parent, int style) {
        this.style = style;
System.out.println("CellEditor constructor");
        create(parent);
    }

    public void create(Composite parent) {
        Assert.isTrue(control == null);
        control = createControl(parent);
   }

    protected abstract Control createControl(Composite parent)
}

Continue reading "Don't call overridable methods in constructors" »

July 13, 2007

Acceptance Testing and Eclipse Rich Client Applications - How to do it?

In my last post I promised a post about something other than Eclipse for my next post. I'm sorry I lied, I had the best of intentions. However the problem of acceptance testing and Rich Client applications has been rattling around in my head for some years now. A couple of years ago I tried this in .NET and didn't have any great success. This time driven by the needs of several projects in my group and reading Bret Pettichord's excellent seminar "Homebrew Test Automation" (PDF) I'm inspired to try again.

Continue reading "Acceptance Testing and Eclipse Rich Client Applications - How to do it?" »

July 11, 2007

Eclipse Madness - Why do fragment plugins work for some Developers and not others?

If you don't do development work in Eclipse - stop reading this post now, come back tomorrow I promise that I will write about something else.

We’re writing our test plugins as fragments to be hosted inside the plugin they’re testing. Most of the time this works without a hitch and gives the benefit of being able to test classes and methods with package (default) visibility. We have several of these plugins that work with no problem both in my Eclipse IDE and our PDE builds. However for one developer one fragment plugin suffers the problem: Host bundle 'xxx.xxx.xxx.common' exists but is unresolved.

What does this mean? What is Eclipse saying? How on Earth do I debug this?

Continue reading "Eclipse Madness - Why do fragment plugins work for some Developers and not others?" »

June 21, 2007

Developing Eclipse RCP apps? Want access to Display etc will running your Unit Tests

For those of you spend your days working in Eclipse and trying to build rich client applications (RCP) the following piece of arcana will be useful. As your developing RCP applications you will undoubtedly need to test classes that require the Display, access to Graphics or other classes that require a running Application. When I first encountered this problem I thought that I was boxed in by Eclipse - but thanks for the work of David Saff you can. The secret sauce: JUnit Plugin tests.

 
  1. To run the tests choose ‘Run…’ either via the context menu in the package explorer or via the Run menu item.
  2. Choose JUnit Plug-in test (not plain old Junit) This provides the tests with access to their plug-in’s plugin class – very important if you want to access the filesystem or other resources under eclipse’s control (Display, ...)
  3. Use the new button either top left of the dialog or via the context menu. A new test will be created that should have the plugin/package/testcase that you selected as its target.
  4. Switch to the main tab and under ‘Program to run’ switch from org.eclipse.ui.workbench to [No Application] – Headless. This avoids have an IDE popup and disappear at the start of your tests. On my machine this shaves 3-4 seconds from the test startup time.
  5. Switch to the plug-ins tab and the 'Choose plug-ins and fragments' radio button
  6. Click 'Deselect All' the existing plugins.
  7. Select your test Plugin.
  8. Click 'Add Required'. In theory this shouldn't make any difference in startup times since Eclipse shouldn't be loading these extra plug-ins. In reality I can spot a one to two second difference

I strongly recommend creating one configuration for the each test plugin so that you can run all the tests for that plugin to see if changes you’ve made break any tests.

One last thought: Test plugins should be created as plug-in fragments to gain the benefit of being able to the benefit of package level access to the classes they’re testing.

BTW if you're getting tired of the Eclipse related stuff don't worry this will be the last for a while.

If you enjoyed this post, subscribe now to get free updates.

June 20, 2007

Narrow Figures - Wide Labels - More GEF discoveries

Most of you aren't developing GEF applications on top of Eclipse RCP - in your case move along there's nothing to see here. However if you're one of the three people out doing GEF development, sit down I have story to tell.

I wanted a label attached to my figures that was wider than the parent figure. The label should be tied to the parent - but not be included in the parents grab handle. The previously suggested solution that I found was to stack the original figure and label in a composite (using a Flow/Toolbar Layout to position the children). Sadly that just created the Ugly Duckling (left figure) and not the Elegant one (see right).

UglyDuckling

After some more digging I discovered an interface HandleBounds (dig the crazy name), its tailor made for this situation:

HandleBounds Identifies figures which use an alternative rectangle to place their handles. Normally, handles will appear around a GraphicalEditPart's figure's bounds.  However, if that figure has an irregular shape, it may implement this interface to indicate that some rectangle other than its bounding rectangle should be used to place handles.

If you ignore the word irregular this solution is tailor made for our problem.

Continue reading "Narrow Figures - Wide Labels - More GEF discoveries" »

AdSense

  •  
    Web Notes From a Tool User

Amazon Store

Blog powered by TypePad

TheGoodBlogs