Thursday, November 7, 2013

Moving to SQLite for storing application settings

So it's been a while since the latest updates. The biggest reason is because I have been busy with a lot of other stuff lately but it is also due to what it is that I've been working on regarding Stoffi.

If you've followed Stoffi on Facebook or Twitter you'll know that I've been working on a new version for OS X. While doing this new version I started to get myself stuck in some serious crashes. After a lot of investigation I found out that the reason behind the crashes was how I was storing application settings in Stoffi.

Since the start of Stoffi, settings have been stored in XML format using the ApplicationSettings which is built into .NET. This has some downsides which have been discussed in various bug reports. The biggest issue is that reading and writing is extremely slow. Somewhat related is that whenever the settings are updated the whole application will freeze for a second, which is why I decided to save the settings only when Stoffi is closed. The result is that Stoffi needs to spend a lot of time reading and writing settings at startup and shutdown.

So for a while there has been some discussions about moving to another backend for storing settings. Both SQLite and some form of NoSQL database has been suggested. However, this move would mean a lot of work and could break a lot of stuff.

When I got stuck in crashes while working on the OS X version however, I was more or less forced to fix this long standing issue. So for the last months I have been slowly working on rewriting the whole part of Stoffi which saves every setting of Stoffi. At the same time I have been juggling 133% study pace and helping out with Haylie.

But today I can finally say that the new system is working and is pretty stable. I have verified that it works on both OS X and on Windows. There's some spit and polish left but most of it is there.

So what are the benefits? Well they are there but you probably won't notice them too much. Stoffi will now have a slightly faster startup and shutdown which is nice. Settings are also now saved as soon as you change something. So if your computer crashes or Stoffi is for some other reason not properly shutdown, you will get right back to where you were the next time you start it. This is pretty sweet for those of us who are in the habit of abusing Stoffi pretty heavily by crashing it and shutting it down in the most merciless ways.

A downside is that you can't just open the settings file and edit it in notepad anymore. Now you need to download the SQLite client and have some knowledge of SQL if you want to mess around with the settings. But if I know my users well this won't be much of an issue for most of them.

So, with this large rewrite finally done I can go back to some other cool work. I plan on implementing playlist management in the OS X version before I move on to releasing the pending upgrade to the Windows version. If you want to help speed up the process head over and download the beta version of Stoffi and report any issues you find.