You'll tick when I say so and not before!

| 0 Comments

Today we wrote some complicated FX business logic tests. Things like making sure that the FX library can calculate a EURUSDCAD 1M rate - it can; or a USDCAD ON rate - it can't and nobody had spotted the fact that it was out because it's way down in the 0.00001's of the rate.

It has taken us around a week to get here. The initial code was a tightly coupled mess. The current code is still a mess; but it's less tightly coupled and it's detached from the GUI code.

The mock live data provider that we wrote last Friday is now fully operational. You can set it up to provide dummy data for a specific set of currencies, add holidays if you like, set "today" to whenever is convenient for the test in hand and then force particular data points to tick with whatever values you feel like specifying and completely under program control. If only we'd had this a month ago when we were trying to track down some of the more obvious errors in the FX rates code.

Tomorrow we instrument the existing 'correct' application so that we can capture some live data and the corresponding output that the FX engine produces. We'll use this data to write tests to prove that refactoring from the live version of the code to get to the testable version of the code hasn't changed anything. Once those tests pass we'll merge this set of changes into the main branch and release it to the users. Once that's done we'll start to verify that the results it produces aren't just in line with the last version but are actually correct as well!

To get to this point we've had to write a lot of support code. What's good is that much of the mock data provider code is likely to be usable when we start refactoring the real "live data" provider. The test harness code is written to be as simple as possible and it does around 75% of what the real data provider needs to do; hopefully we can just hoist it into the Reuters library and fill in the gaps.

The FX library is now in a state where the final bits of refactoring can be done. These are the scary parts of the code, the convoluted rates calculations that bear no resemblance to the examples in the FX books we've been using for reference. The good thing is that now it's not scary code to change. We have a full test harness for the library and we can experiment with reimplementing the calculation code when we're writing tests to test the existing code. I expect we'll see a lot more code moving from the test harnesses into the production code.

Let the refactoring commence!

Leave a comment