A collection of thoughts, ideas and rants inspired by my career in the fintech and banking industry.

Synchronized code in distributed systems

I encountered some code recently where a GUI client was listening for Object updates from a multi-threaded server, and it was using the version number on the Object to determine whether the incoming Object was the latest version. The server incremented the version of the Object by inserting a new row into a table in the database and using the primary key as the version number.

Now consider the case multi-threaded case where two threads, T1 and T2, are making updates to the Object.

[Read More]

Learn To Type!

If there was one piece of advice I could give to someone considering a career in software development it would be: Learn to f$%@cking type! Knowing how to touch type is the single most valuable skill that a developer can possess.

Typing allows you to concentrate on what you’re coding rather than how to get the characters on the screen. In other words, you’re able to think about the code rather than thinking about where to find the letters on the keyboard. Jeff Atwood and Steve Yegge both make the same point.

[Read More]
Typing 

Reflection HashCodeBuilder Performance

I recently embarked upon a performance investigation to figure out why a particular operation was slow. My theory was that it was the serialization/deserialization cost with a set of large objects; my colleague’s theory was the iteration over the set. We were both wrong.

The investigation became intriguing when we started measuring the elapsed time at various points in the application and noticed that the bulk of the time was being spent in a seemingly innocuous call to construct a HashSet from an existing Collection.

[Read More]

A new assignment

My ex-project and I had been together for ten months. We had our fair share ups and downs, particularly in the early days, but over the last few months we had settled into a nice routine. It wasn’t particularly exciting any more but at least it was predictable.

And then yesterday I was asked to lead a troubled project. It’s only six months old and already has quite a few warts, and it limped across the line into UAT last week. My first instinct was to cower in the corner in the fetal position but I resisted that temptation and quietly accepted the role.

[Read More]

How to insulate yourself from static methods

Sometimes your code needs to call a static method in a 3rd party library and unit testing  suddenly becomes difficult, particularly when that static method requires context in order to work.

Enter the insulating class (also known as a Facade).

  1. Create a new interface that declares a method with the same signature as the static method you want to delegate to
  2. Create a new Facade class that implements the interface
  3. Replace the calls to the static method with calls to your new Facade class

Let’s assume that the method you need to call looks like this

[Read More]

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.

  • You must specify a -vm argument in your “eclipse.ini” file (in your Eclipse directory).
  • The -vm argument in your “eclipse.ini” must point 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.

[Read More]

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)

[Read More]

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.

[Read More]
Agile 

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.

[Read More]

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.

[Read More]