
Journal Journal: Introducing Bean Sheet
They say a lot of discoveries and inventions happen by accident. In the fall of 2003, I was preparing for a job interview. One of the requirements for the position was proficiency with Swing. I knew Swing, but it was some time since I'd used it so I figured what the heck, might as well brush up on it.
A good all-around Swing project is writing a spreadsheet. You get to do a bunch of MVC, think about renderers and editors, and play with JTable, arguably one of the funkiest widgets in the Swing widget set. As I embarked on the project, everything went well right up until the point where I realized I needed a formula parser. The urge was there, but thankfully I didn't rush into writing my own.
I had been using a really nice Java parser called Bean Shell for some time and knew it was just the thing I needed. The neatest thing about Bean Shell is that it's a loosely typed superset of the Java language itsef. As such, there is no need for anyone who knows Java to learn new syntax. As a language superset though, it also implies that the very basic formula syntax of arithmetic and string concatenation so widely used and understood even by any old Excel user. At the same time, Bean Shell has extensible commands that are also very easy to understand and use. And to boot it all, Bean Shell was made with embedded use in mind. To sum it up, with no effort on my part, I got the basic formula engine functionality I was originally after as well as the full power of the Java language and Bean Shell command extensibility that gave me the potential to give a user a full set of traditional spreadsheet functions such as sum and average. What could be more perfect?
It took next to no time at all to get the core functionality working. In just a couple of hours, having started with nothing, I had before me a spreadsheet that could evaluate cell references, Java-compliant code, and any Bean Shell commands and their extensions I wished.
Over the following weeks, I spent some time improving GUI and adding standard expected features such as opening of and saving into files, clipboard functionality (copy and paste), etc. At this stage, I am anxious to get it to the point where it's really easy and intuitive to use. But my main goal is to create a framework that can be easily extended, just like with Apache modules. That way it will be a compelling and powerful tool, rather than an overgrown software engineering experiment. Below is the list of foreseeable goals, achieving which would warrant a beta release:
- Persistance format refactoring.
- Currently, Bean Sheet implements persistance through a very simple and inflexible serialization model. Java object serialization is not the problem, but the logic certainly needs to be modularized so as to potentially support other persistance schemes and be more flexible with regard to the data it accepts (backward compatibility).
- XML persistance module.
- One obviously good thing is an XML interchange format. Coupled with XSL, this bit of functionality can give one an amazing array of uses and interoperability with other applications, services, and standards.
- Collaborative editing module and server.
- A very interesting trend in spreadsheet tools today is to let multiple users concurrently work on the same set of data without conflicting with one another. Spreadsheets inherently benefit from this sort of functionality and allow people to not only use centralized data servers, but also provide flexibility in the choice of a client, which is especially compelling in the context of mobile devices and thin clients. This is obviously a major topic and deserves a discussion of its own.
- Graphing module.
- Clearly, graphing is a must in all spreadsheet applications these days. It does not always need to wield the power of a full-fledged reporting package, but some graphing and charting functionality is needed. One candidate library is JChart.
- J2ME version.
- Imagine all the great stuff mentioned above running in your hand-held! In theory, it shouldn't be too difficult to get it running in at least some flavors of J2ME. The core of Bean Sheet only requires Swing and Bean Shell. If need be, Swing can be factored out of the equation and some other table rendering library can be found or written, though of course it would be better to avoid that scenario.