Two Eclipse Icons in Windows 7 taskbar

I had an annoying problem on Windows 7 x64 with Helios x64 where I had pinned Eclipse to the taskbar but would see two icons whenever Eclipse was running. I found that the following workaround works with the option “Always combine, hide labels” for taskbar buttons.

  • Check your “eclipse.ini” in your Eclipse directory for the specified VM and make sure the path points to the bin directory of your JDK or JRE (and not to javaw.exe). For me the argument is “C:/Program Files/Java/jdk1.6.0_27/bin/” without quotes.
  • Unpin Eclipse from the taskbar or delete the shortcut
  • Run “eclipse.exe” from Windows Explorer and choose your workspace
  • Pin Eclipse to the taskbar after the splash screen has loaded and the main window is shown

Hope this helps.

How to divide without using division operator

I attended a talk at the Toronto Agile Tour on Deliberate Practice that focused on TDD Games and other programming challenges like Kata.  Among the challenges were things like solving a problem without using the ‘if’ keyword, or without using primitives.

Solving simple problems using these challenges makes us better programmers because they force us to come up with multiple, creative solutions to the same problem.

Here’s my solution for how to divide without using the division operator (“/”) in Java. The method should take a numerator and a denominator and return the largest integer multiplier. For example 10/3 = 3, which would be called as int result = divide(10, 3)

public interface DivisionOperator {
  int divide(int numerator, int denominator);
}
/** ************************************* */
public class Division implements DivisionOperator {
  public int divide(int numerator, int denominator) {
    if( denominator == 0){
      throw new IllegalArgumentException("Denonimnator cannot be zero");
    }
    int i = 1;
    while( denominator * i <= numerator){
      i++;
    }
    return i - 1;
  }
}
/** ************************************* */
public class DivisionTest {
  @Test
  public void testDivision() {
    checkDivisionOperatorImplementation(new Division());
    checkDivisionOperatorImplementation(new DivisionAlternateAnswer());
  }

  private void checkDivisionOperatorImplementation( DivisionOperator div){
    try {
      div.divide(0, 0);
      Assert.fail("Expected divide by zero error");
    } catch (Exception e) {
      // Expected
    }
    Assert.assertEquals( 0, div.divide(0, 10));
    Assert.assertEquals( 3, div.divide(10, 3));
    Assert.assertEquals( 0, div.divide(3, 10));
    Assert.assertEquals( 1, div.divide(3, 3));
  }
}

I came up with a few implementations (hence the interface, makes testing much easier) but I think this one is the cleanest. I’m pretty sure there’s a solution using bit shifting but let’s face it, most developers don’t use bit shifting in their code.

Keep calm and carry on

“I’ve had a talk with the Product Owner, and he’s decided to let you guys have an extra week to finish the work for this Sprint”, my Project Manager said on Friday afternoon.

The horror! The horror!

My team and I did not manage to complete all the work that we’d committed to in the Sprint.  In the interests of open communication, I informed my project manager that there would be a few carry-over items.  The next thing I knew I was being told that we would get a Bonus Week in our two-week Sprint so that we could complete the functionality.

It’s when the crunch is on and there’s pressure to meet a deadline that we need our Process most. It is there to protect us from doing Dumb Things. We need to write tests, we need the continuous build to pass, we need our two-week Sprints.  That’s what makes us successful.

However, it’s during these same frantic periods when it seems reasonable to break process. It’s justifiable, they say. We can circle back and mop it up later. But the shortcuts make it into production and cost us in support time, triage, and bug fixing, and they make us gun shy when it comes time to release again.

I’m upset with myself for not pushing back – I should have refused to extend the Sprint. I know this Bonus Week will come back to haunt us, and the context will be lost when it comes time to explain what transpired.

Defend your process in times of pressure.

How to be Agile when using 3rd party software framework

It can be difficult to be Agile when working with 3rd party software framework.  The vendor product may dictate many aspects of the software architecture thwarting your attempts at automated testing and continuous build.

However there are steps you can take to make Agile easier.  I’ll discuss a few of the options that have worked for me on my current project.

  • Insulate yourself from static methods.
  • Introduce wrappers (Facades) to vendor classes.
  • Introduce Spring, with different contexts for testing vs production, to allow easy substitution of vendor classes.
  • Make use of mock objects for testing your code in isolation.
  • If possible, move responsibility into services that live outside the framework.

In our particular case we’ve done all of the above and have managed to build a stable system with respectable test coverage.  We’ve also engaged the vendor to see if they can modify some of the framework interfaces to simplify unit testing, and they have been open to our suggestions.

ControlTier: Initial Impressions

For the last 2 months, we’ve been using ControlTier to automate deployments to our integration and QA environments.  Our deployment is a little more complicated that most Java applications because it runs on a pseudo-grid.  That is, there are 2 clustered JBoss servers, a database server, and 4+ Linux servers that each run about 8 Java processes.

I was able to get ControlTier up and running in a few days, and defining the jobs was relatively straightforward.

Features I really like include:

  1. Tagging nodes. This allows me to run, for example, the JBoss startup on all nodes tagged as “jboss”.  If I add a new node I don’t have to modify the job.
  2. Composite jobs. I can define small, single-purpose jobs and combine them into larger jobs. Code re-use, if you will.

There are a few features I’d really like to see:

  1. A Jenkins plug-in.  Deployments to the Integration environment always follow a successful build.
  2. Simpler parallel job configuration. I can start all Java grid processes simultaneously, but haven’t figured out how to get ControlTier to do it.
  3. Ability to configure environments and run the same job against multiple environments rather than having to copy the job and change its project or target nodes.
  4. Synchronous job execution. Although this may not be necessary if there was a Jenkins plug-in.

Overall I’m happy with what ControlTier is doing for us.  If I get time, I’d also like to compare it to other deployment frameworks like RunDeck.