Demo 2: Units & Decimal places & a surprise!
Hello spreadsheet nerds! I'm ready to show my next batch of working code.
This update is jam packed with features!
- Units - You can now say that a cell contains Currency, Percents and Distances, just by writing the value in a natural way (eg.
$100
or100ft
) - Decimal places now round in sane ways based on the data you've entered. It will also show a small symbol when the data being displayed isn't the full value being used for calculations. And of course: special currency handling - always round to 2 decimal places.
- SI symbols! So that
100km
is understood to be 100,000m - Underscore delimiters in numbers: because 300000 is much hard to understand than
300_000
Demo time!
If you can't tell, I'm really excited about this update and specifically how well the inheritance model works for units. The video demonstrates it well, but when you use units for values, downstream calculations use those units and they show without any work by the user. This feels really natural and it's easy to forget that it's happening.
Check out the video to see it in action:
There's also a surprise feature that is one of my favorites and what I think will become an important feature for the app. I'll write a bit more about it in the next newsletter. If you don't want to watch the full video, you can skip to 3:45 to see its part of the demo.
With these features implemented, I can now support a retirement planning worksheet, as shown in the demo, so that's a major milestone! Adding a type for Dates (and years/days/etc) will be another helpful step to making that more useful.
Implementation thoughts
This update took longer than I expected. Implementing the basic support for units was straightforward and quick, but there are a lot of corner cases. I ended adding 165 new test cases just for the interplay between the different features and between the different units. Some interesting(?) corner cases include:
- What should the result of 3%*4% be?
- What about 3+5% ? should that be
3+0.15=3.15
("3 plus 5% of 3") or3+.05==305%
("3 converted to percent plus 5 percent results in a new percent")? - Should I support
100ft*5%
as the way to get 5% of 100ft (which is how it works in spreadsheet apps today?) or should I make a new operator5% of 100ft
? - what about 5 + 100ft? should that be an error (units don't match!) or should it just work?
In most cases, I ended up deciding to stick with the existing spreadsheet behavior for compatibility reasons (or throwing errors when I worried it could cause calculation errors), but there are still a lot of interesting possibilities introduced by understanding units in equations and I look forward to feedback from users once I've got it in your hands.
The demo creation process is a great way to really exercise the code, since it forces me to fix errors that I just skip over when I'm using the app just for myself. I turned up and fixed a lot of valuable usability bugs this way.
Next up!
The next big feature I plan to work on is persistence (aka saving and loading.) The goal is that after the next milestone I'll perhaps be able to make the app available for dogfooding, which is exciting.
I might write up some more details about the persistence model I'm planning to use, since it won't be the standard "stick it in sql server".