PersonalFinancier gets an Aussie Inflation Calculator

I have a hobby programming project that has been mothballing until about a fortnight ago, when I decided to risk trying pushing some new functionality out.
I call it PersonalFinancier, and it’s hosted on GitHub under an open-source licence.

Since finishing the budgeting functionality, the itch to push the functionality out pretty-much stopped. I’d answered my cash-flow concerns, and was once again in that pleasing place of being certain that it was alll ticking over quite happily without my needing to watch it closely.

PersonalFinancier's Budget Tab @ 10/05/2013`

PersonalFinancier’s Budget Tab @ 10/05/2013

Lately, I’ve been itching to answer a new financial question that ultimately needs me to compare monetary values across over a decade of elapsed time. Now… I could just have visited the ABS, and used their inflation calculator, but where’s the fun in that? I’d written something very similar way back in the early 2000s when I was first cutting my teeth on Java, and frankly, looking at that code now is pretty painful. I decided to nuke it from orbit, because let’s face it… it’s the only way to be sure!

Tonight, I pushed the last commit up to GitHub that implements my Inflation Calculator. Though the calculator looks similar to the original in terms of its user-interface, the guts of it was a complete rewrite.

This flash new calculator involves two separate inflation models. The base model captures and manages CPI figures published by the ABS (or if you care for some serious scenario planning, a completely fictitious set). The second model is devoted to the calculator itself, and acts as one of the MVC viewers to the base model, the other viewer being the table widget used to render the CPI figures.

PersonalFinancier's Inflation Tab @ 10/05/2013

PersonalFinancier’s Inflation Tab @ 10/05/2013

It also takes a “favour composition over inheritence” approach to constructing the GUI. Inheritance of GUI components is a weakness that I’ve been known to fall into in the past, so this build has been a deliberate attempt to construct a rich GUI experience without defaulting to a deep nested inheritance structure for my tweaked Swing widgets.

Right now, the CPI figures are stored as a JSON encoding of the data, making it dead easy marshall between POJO and serialised state via that sexy little open-source library Gson.

In fact… here’s a link to the CPI figures as a JSON encoding. Building a POJO to match I leave as exercise to the reader. No promises I’ll keep it up to date unless someone reminds me that I’ve let it get stale.

Next step… putting a pretty graph into that unused panel. Here’s to the kids keep up their disinterest in my nightly itch-scratching.

64bit Assembly Blues: Now With NUnit Goodness!

I made a terrible mistake this morning.  I decided I wanted to just double-check that my unit tests were still working, given my recent move to a 64-bit version of  Windows, and the subsequent meltdown of my development environment.

In Linds happy-clappy land, I’d get a quick display of green ticks across the board, and feel comfortable that my safety net was still doing its safety-net thing. In Linds horrifying-reality land, various failures broke my expectations harder than a two-tonne heavy-thing.

I won’t bore you all with the boring detail of the full path taken.  Instead, let’s cut to the chase, and leave some notes on what went down.

A 32-bit install of Office triggers a need for a 32-bit Office interface library, triggering a need for the assemblies that rely on it to go 32-bit. This then triggers a need for NUnit testing libraries to be compiled 32-bit. Because I’m the cutting-edge Nunit (currently version 2.6.2) it attempts to run against .Net 3.5 by default. I needed to coax it into running .NET 4.0, by modifying the Nunit.exe.config file as described here.

After all that, I’d be right, RIGHT? Wrong! My familiar old friend BadImageFormatException is back, and out to deny me any and all of the unit-testing love I need:

Testing a 32-bit assembly with a 64-bit NUnit install

Testing a 32-bit assembly with a 64-bit NUnit install

So Nunit was all like:

then I was all like:


Until, in a pique of frustration, I saw the 32-bit version of NUnit sitting in the same Nunit program folder.  I pulled the same trick above for the 32-bit executable’s config file, and tried running the same unit test assembly. Success!

32-bit NUnit version runs your 32-bit Test Assemblies!

32-bit NUnit version runs your 32-bit Test Assemblies!

Note to self… this mixed 32-bit/64-bit chain of dependencies is so very fragile. Must remember to carefully ensure the entire stack is properly aligned (or set up a 32-bit development virtual machine, and leave this dope to the junkies).

Between you and me peeps, I truly hope this is the last of my 64-bit upgrade fallout. After this experience, I’m finding it very tempting to take an attitude in future work to lock down the single architecture the software will support (dictated, probably by 3rd-party library limitations), and ensure that the development environment is fully-set up for it.

I Got Your 64 bit Upgrade Right Here Punk!

I have been warned that come mid-year, I’ll be trading in my office with a view for returning to an open-plan experience in the newly constructed Sir Samuel Griffith Building up here on the Nathan campus. Beloved view, I love you!

The view from my office

The view from my office

As you might understand, I’m a little mixed about returning to an open-plan experience. It really isn’t conducive to going and staying deep in the flow, and you’d think that after research on what facilitates flow, maybe peeps would get the message that open-plan layouts actively work against certain kinds of productivity. Then again, I was raised on the open-plan experience, and this being my first “own office” experience, there’s not much shock expected.

I’ve heard that the open-plan nature of the building falls out in the wash whilst maximising amount of natural light coming into the building, reducing its carbom footprint. So, what we’ve got here peeps, is an attempt to find a sweet-spot between an environmentally sustainable building played off against maximising people’s output. I guess only time will tell on how well these researchers can maintain their flow in the new environment. Still, I feel for those researchers, entering the world of prarie-dogging for the first time.

So, in preparation for a move to the new building, our IT team has just returned my laptop. Gone the 32-bit Windows XP operating system. Hello to a 64 bit Windows 7 upgrade. The 64-bit thing was a surprise. The consequent breakage of my development environment was not. Though, now I’ve had some time to investigate it, I’m now able to describe the particular nature of my non-surprise.

It seems that we have a 32-bit install of Microsoft Office on our 64-bit machines, thanks to some incompatibilities with other 32-bit software that is in common use on campus. My “Species Benefit Optimiser for the Murrumbidgee Wetlands” relies on Microsoft Excel to import model data through the usage of the ACE Database engine. As Excel is 32-bit, I need the 32-bit ACE library.

Though I can compile my tool to use “Any CPU” as my target platform via Visual Studio, I get this fun little runtime error unless I specify a target platform of “x86″, guaranteeing that the 32-bit ACE driver gets picked up and used for conversations with Excel:

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine.

If I DO compile it against a target platform of “x86″, I get this runtime error instead:

BadImageFormatException

BadImageFormatException

Which is in many ways worse, because my most foundational support library is apparently borked, as opposed to just a rogue Microsoft library that with a little more work, could be made optional.  Lots of interesting trawling ensued.

Once again, StackExchange delivered the non-nonsense heart of the issue.  Ihe VisualStudio debugger is running 64-bit, and has a cow trying to debug a 32-bit application.  I tested this out and confirmed it for myself.  I can run my application just fine from within VisualStudio so long as it’s not with the debugger.

I’ve considered and rejected a lot of workarouds.   The winner is an approach where I coax VisualStudio to run its debugger as a 32-bit  application. They tell me I need to run a command from the VisualStudio command prompt in administrator mode.  Here’s a picture of  that happening:

Running the VisualStudio Command Prompt As Administrator

Running the VisualStudio Command Prompt As Administrator

They also warn me that the command modifies the debugger executable, meaning we’re taking an all-or-nothing approach to debugging 32-bit applications.  As I may want to get back to 64-bit applications, here’s another picture of me keeping both a 32-bit and a 64-bit backup of the exeutable, so I can toggle this hackery later:

Creating a 32-bit Debugger... carefully

Creating a 32-bit Debugger… carefully

And done.  The debugger is working again on my 32-bit application, though this degree of hackery last left me shaken, not stirrred.

The End of the TRaCK?

In September 2010, I started a software development contract with the Australian Rivers Institute. That first contract, being an integration sub-project of the TRaCK program, is well and truly finished from my end, except for an outstanding journal manuscript. Part of the reviewer feedback quite rightly argued that the submission would have been much stronger with supporting publications that currently haven’t been submitted.

I’ve been naval gazing over whether to keep pushing for a publication of the manuscript or to let it slide. I realised at the end of the PhD that I’m just not that driven to step onto the ‘publish or perish‘ treadmill. That our key users ended up getting value out of the software we built scratches my professional itch sufficiently. Still, the manuscript is written, and It would be nice to have something in a journal to do the research and modelling we conducted on the Daly River in the Northern Territory some justice.

The MSE Data Viewer showing the Daly River

The MSE Data Viewer showing the Daly River

This morning I got feedback from my old boss on the state of the other unpublished papers. It’ll be a while yet, as he’s currently still recovering from the project by sailing around the world. I’m pleased for him and and glad he’s taking all the time he needs to get over the last few months of the project, where he was devoting every waking moment to it.

So, now I’m left in a zone where I’d like to at least wrap things up, and a leave a Web-based paper-trail for anyone interested in my own contribution to TRaCK and the Management Strategy Evaluation software (MSE for short) in particular.

Rich Graphing via the MSE

Rich Graphing via the MSE

Firstly, I had an interview on my role in TRaCK about mid-way through the project to describe the MSE to other researchers within the institute. Jon the interverwier and I spent quite some time ironing out technical jargon from two very different fields of expertise. For any software engineers reading the interview, be warned that I eventually called good enough knowing that it still sounded a little odd, but that the primary audience wouldn’t appreciate any further corrections to appease my pedantry.

The Layered Architecture of the MSE

The Layered Architecture of the MSE

Secondly, here is a thorough final report detailing the MSE software and how it was used in the Daly River catchment in the Northern Territory. It was produced for a target audience of researchers and natural resource managers. As proof that I’m capable of more than just developing software, chapters 2, 3 and Appendix A are my contributions to the report.

Finally, the boss wanted me to cook up an ‘under the hood’ document, describing the software in sufficient detail that a software developer could read the report, pick up the software source, and begin again as quickly as possible. For those wondering what kind of document I’d write on the architecture and design of software when given free reign, this is it.

So there you have it. A few artefacts I can point to after the completion of the project to establish some street-cred with respect to my time on the TRaCK project and the MSE application.

CamelCase to Readable Text in VB.NET

I recently had a need to take Enumeration instances from within .NET and pretty them up for human consumption. The heart of the problem involved how to take CamelCase text and add spaces between each word-break denoted by a new upper-case letter.

I’m mostly following the Microsoft internal coding guidelines for my naming conventions.  Enumerations should thus be mostly PascalCase/Upper Camel Case, but I’m not above just grabbing external libraries and gluing them into the utility, risking oddities that don’t match the guideline.

Given that I can’t predict ahead of time how well the enumeration sticks to a strict PascalCase naming scheme, I wanted a regular expression that would cater for a wider range of strings than ‘strict’ PascalCase.  I learnt that a programmer can drive themselves crazy catering for a rich range of possible encodings, so I decided to draw the line at strict CamelCase along with PascalCase, ignoring non-word characters for the time being.

Now, all languages have their little quirks with how they implement regular expressions, and .NET is no exception.  Thankfully, after a little digging around, I discovered a good launch-point out at StackExchange based on somebody wanting to do a very similar thing in PHP. Very little messing around was required with my favourite expression’s syntax, which is always a pleasant thing. The final expression settled on was:

"(?<=[a-z])(?=[A-Z])"

Interpret the expression thusly:

Look for a pattern that forms a boundary between two characters for valid CamelCase.  On the left-side, seek a lower-case character (a-z). On the right-hand side, seek an upper-case character (A-Z).  On the left-side, do what’s called a zero-width positive look-behind assertion to identify the lowercase character without moving the pattern matcher along the string.  On the right, do a zero-width positive lookahead assertion in order to identify the spot here the new upper-case character in the string without consuming it in a pattern match. The split is to be made so the upper-case character starts a new string.

This blog post is essentially me saying to myself “Ok.. I can see that it works… but WHY does it work?” and deciding to scare whoever else out there likes the occasional good Regular Expression brain-twist.

A chunk of VB.NET code that makes PascalCase/CamelCase text into something more easily consumable by a human is below. The regular expression is created ahead of time outside the function for runtime efficiency.


Imports System.Text.RegularExpressions

Private CamelCaseRegex As New Regex("(?<=[a-z])(?=[A-Z])")

Public Function CamelCaseToHumanReadableString(
                  ByRef inputString As String) As String

  Return String.Join(
    " ",
    CamelCaseRegex.Split(inputString)
  )

End Function

CamelCase for your human consumers long and prosper!

You Got No Say In It

So there I am, standing in what I’ll call a pre-undergraduate motivation-collapse coffee line, waiting for my afternoon hit. In a month or so, The Slackening begins, and I can get back to just walking up to the barista and getting my afternoon hit of my last-great-crutch.

Behind me are two first-year girls bitterly criticising a mutual male friend of theirs for his decision to quit University and do something he thinks he’d enjoy more. From what I can piece together, it’s to do with serving people in the 3rd-world in some capacity. A noble calling for those who hear that tune calling their name on the wind.

And now that I know what I’m looking for in these conversations, I recognise that I’m tuning into an absolutely gluttonous gorging of fear-programming around lack of time and money. These girls are true believers, beating out a relentless dirge of doom whose predicate is a foolish young man’s desire to do something he might enjoy more than plugging into the career ladder-climb ASAP.

Now.. this wouldn’t be much of a story except for the fact that I wasn’t really listening. I’d slipped comfortably into unplugging from my thoughts to give my own story-teller a rest from a typical litany of programming around a lack of time.

Coasting on the sound of their voices and the background radio trying to drown out a hundred such conversations around it, the subconscious finally smirked its familiar “got a pattern I’m enjoying” smirk at me and jogged me out of timelessness to hand me the recognition that I was hearing this song:

So there I am… ordering my latest mug of mud-coloured crutch; re-acquainting myself with a song I loved (but didn’t really grok) as a child.

I’m thoroughly enjoying the little mental gender-bending real-time filter tweaking required to fully align the song’s message with the judgement coming off these two girls, working it into a pretty little visualisation of balanced scales.

Good luck ladies. When your time comes to accept that dancing to the tune of another’s fear only pays dividends in a currency of sorrow, we might be ready for an interesting conversation. Sounds like your friend is already in a place I’d appreciate a deeper understanding of.

If you love a Minecraft construct, set it free

I spent a bit of the weekend consolidating most of my Minecraft constructs into a single world with WorldEdit, given some tentative musings around setting up a home server. You see, my eldest has been going full-tilt into creating fantastic worlds of imagination and recently wondered aloud if we could build in the same world.

In doing the move, it occurred to me yesterday that surely there’s a web-location where peeps share their minecraft schematics. Lo and behold! Minecraft-schematics.com.

Doesn’t seem that popular at the moment, but never-the-less there are some stunning consturcts already up. So, you’re now free to take copies of the things people build and post to this site. As The Culture so elegantly put it, “Superiority through Redundancy!”.

There are a few more to go yet, but so far I’ve uploaded those that didn’t need much love:

And here’s a gallery of the schematics embedded in a test world:

This slideshow requires JavaScript.

So, if you have some Minecraft schematics you’re looking to house remotely, and are happy to share what you’ve built, consider joining me in populating Minecraft-schematics.