Monday, 10 August 2015

My new notes program

I've been working in my lab on something new, or a new version of something old. First, of course, I need to give you some background.

I have a note-taking program I use every day that saves text files to Dropbox, based on hashtags I supply for each note. I also have several computers, some of which are offline sometimes, because I write on the train or have no internet access at work or just haven't switched on my desktop in a day or two. All of this combines to cause problems with the text files - namely, conflicting edits. Dropbox helpfully preserves each copy of the file and I can usually mash them back together again, but sometimes I can't, or it's a lot of work.

So I've written a new version of my note-taking program that doesn't suffer these problems. It uses a design called event sourcing which means that, instead of writing the text files directly, I write a record of the events and actions that occurred, like making a new note, editing an old one, attaching tags and so on. What this means for the program is no more conflicts, or at least not the same kind. Each event is written to its own file with a unique generated name, so they never conflict when Dropbox synchronises. Everything is always perfectly and effortlessly preserved.

The down side is that I am no longer working with plain text files. I can't just open up a text editor and change an entry, or delete it. I need to go through the proper channels to make sure the event stream is preserved. For the sake of never having another conflicting edit in my text files, though, I think this might be worth it.

Mokalus of Borg

PS - It's still in testing, but it's coming along very nicely. From the UI, you can hardly even tell that it's changed.
PPS - The library and pattern will be used on all my other similar programs from now on, too.

No comments: