The Ultimate Business Machine - Archives
List of Categories : Database * Technology * Commentary * Singapore * Travel *
Sun 24 Sep 2006
Category : Technology/journey.txt
It started with the question - do currencies always round to two significant digits, like US$9.99? The answer is no. There is at least one case, the Japanese Yen, e.g., ¥1,280 for a pack of Pampers, where they have no decimal places.
So how do we make Luca work universally across all currencies without hard-coding all these things?
The question started me on a journey of discovery where I learnt about NSDecimalNumbers, creating a custom NSNumberFormatter class in Cocoa together with its own Interface Builder palette, and also about storing blob values in SQL databases so I can stash these number formats that the user has created.
And I'm now almost done. I have an interface in Luca that now allows a user to create custom number formats for any individual currency, and he can apply these formats wherever he's entering currency values in any voucher.
If he chooses the Japanese yen as the base currency for the accounting system in Luca, then all calculations where rounding has to be applied (e.g., in exchange rate or tax calculations) are done to zero decimal places.
That's triggered in just one place in the code and there's no hard-coding.
So, to answer my own question : it can be done.
Along the way, I think, I can now really articulate why Cocoa and, especially, Objective-C are such good software development tools.
It's all about design.
You've got to take a Janus-like stance and look both inwards and outwards at the same time.
You've got to look inwards into the code and be aware that the world you're modelling is as complicated as only life can be. And so, you've got to simplify, simplify, and simplify yet again wherever you can in the coding, to get everything neat, clean, crisp and small. Because if you don't don't, then you're going to get drowned in all the possible permutations when things come together in combination, when you meet a real user in the real world.
It's from this perspective that we should value the simplicity of the Mac. And the wonderful pragmatism of the Objective-C language.
And so I continue to simplify Luca. I'm pulling all Luca application settings into one single Preferences window, and I hope I can organise its presentation into a narrative to help the user understand what he has to do to set up an accounting system. If I can get this Prefs window done, then Luca will be reduced to just two menu items - an Accounts menu and a menu for Journal, and that would be about it.