John-Daniel over at Mindscape e-mailed me yesterday at 2:50am (fortunately, he lives in New Zealand…) and suggested I write about the release of Mindscape LightSpeed 3.0. He offered me a LightSpeed 3.0 license free for me to give away in any way I want, which I thought was pretty cool for reasons I’ll get to in a moment. He also wants to entice me to write such a post by offering me a free license of any of their tools, which unfortunately is not as cool, for other reasons I’ll also get to in a moment.
But first, some background…
For the software that I’m developing for my own business I had an absolute nightmare with persistence. My software is a thick client application that will run on people’s desktops or laptops. In an internet age this may be considered a little bit shocking; several years ago I worked for a company that had a decree (delivered from on high) that all future applications would be written for the web. With Google building everything on the web, and Microsoft moving Office to the web, and all the talk about cloud computing it seems the web is the place to be. However, my clients often use their laptops in places without wireless connectivity, the software is doing a lot of computationally intensive stuff so hosting it in the cloud could get pricy quickly, and finally the software deals with very personal data, and my clients are very leery of not having this data secured locally.
Additionally,after interviewing lots of clients, I came to the inescapable conclusion that my clients are not computer experts nor do they want to be. I know this because they told me that in exactly those words. 🙂 So making them install or even attempting to automatically install some form of traditional client-server database was out of the question.
So from the early days when I was designing/architecting my application I knew it needed to use an embedded database.
Forget puritan dogmatism, for me its about productivity and getting useful things done, so I definitely did not want to hand-code SQL for all 500 database entities in my application. Starting a green-field application I also wanted to focus on the domain model and do domain-driven development. The database then becomes a mechanism for persisting data, not the end-all-be-all of the application. So any ORM tools that require building the database and then automatically generate some pseudo-domain-layer were not for me. I spent about a week full-time just finding ORM tools and downloading them and trying them out. Some hadn’t been touched in 5+ years and many were simply gone entirely (which made evaluating them very easy 🙂
So I finally started developing with SQLite, which is a great little free database. Many of the ORMs available do not work with SQLite, which ruled them out immediately. (I did spend a week trying to get Firebird to work as an embedded database, but no such luck, and MySQL is VERY expensive for an open-source product if you need to use it as an embedded database in a product that you’ll be selling!)
I decided to use the Microsoft Entity Framework to communicate with the database, which had just been released about two weeks before I started development and was being pushed hard as the greatest thing since sliced bread. Unfortunately, I quickly realized that the Entity Framework was “twisted and evil”; I found the three layer abstraction great in theory and really lousy in practice, the VS2008 designer was incredibly lacking and buggy, and error messages were so complex not even Google knew anything about them. I tried using Microsoft SQL Compact edition, with the same exact database model I just got completely different complex error messages. So I threw out all that work (it wasn’t much) and started again with good ol’ reliable NHibernate.
Only, I immediately had headaches with that too; for all of the Hibernate croud’s ranting and complaining about the Entity Framework I found NHibernate to be really just more of the same: their puritan dogma of “transparent persistence” is great in theory, but oh by the way we don’t have any GUI for .NET folks so just hand-code the XML (?!), oh, and you just need to make all your properties and methods virtual, so oh yeah your classes can’t be sealed, and you really need to ensure that you only use interfaces for collections (so no someList.AsReadOnly()), and you can’t just have one class have a reference another because that’s really not good database design, etc. It certainly didn’t feel terribly “transparent” and it definitely wasn’t productive. So in the interest of protecting my domain layer I switched to using Castle Active Record. Putting a few attributes on my classes and properties is MUCH better than having to completely change the way I design classes. I still had to jump through hoops when dealing with collections, but everything was much easier and faster.
This worked for several months before the puritan dogma of NHibernate broke through the Castle Active record abstraction and bit me very hard; so I went back to the drawing board.
I decided to use an object database: DB4O. Development has been incredibly fast ever since; everything is so darn easy, I haven’t thought about persistence in months – everything just works.
When a client came to me recently and wanted to build a rich internet application I quickly realized DB4O was the wrong solution. For one thing, it’s single threaded, so it definitely doesn’t fit the internet world. I read about a few people that tried it anyway with poor results. I really wanted to use Eloquera, but they don’t have LINQ support yet (and LINQ is just so darn productive that not using LINQ is stealing from the client). So the hunt was on for a good ORM solution that was easy to use and supported LINQ. Additionally, object databases are (sadly) not really mainstream, so it just wasn’t a good fit.
Fortunately, I still had the evaluations I had done the previous year of every ORM tool out there I could find, so I just researched the top few tools and examined the latest additions.
Mindscape’s LightSpeed had been a top contender before, and it came out on top this time around. Everybody that’s used it seemed to love it, and having used it myself now it really is a great tool with great support. The visual model designer is integrated directly into visual studio and supports both forward (to the database) and reverse (from the database) generation. You don’t have to use the code-generation feature at all (although I do), and what is really great is that it automatically generates data transfer objects (DTOs). These DTOs are all partial classes with many partial methods, so it’s easy to extend them and hook in custom code. It’s very well thought out. They have also responded to every forum post and e-mail in a very quickly.
My client is happy because I am very productive (and he pays by the hour): I can easily design new entities, and use the automatically created DTOs to send the entities to the Silverlight client via WCF RIA Services. (This only required a small change to their code generation templates). I spend most of my time focused on the actual Silverlight application and a very little time worrying about database persistence and wire-transmission. Development the way it should be.
I should mention that I still designed the database-access layer so that it completely encapsulates the use of Lightspeed (although it does expose the automatically generated DTOs). I believe this is just good layered design, although it would in theory allow us to switch out Lightspeed and use a different ORM (what?)
While Lightspeed is Mindscape’s flagship product, their other products don’t really interest me that much. I’ve already got the Actipro WPF Property grid (and I don’t need it for my software) their WPF Flow and Star Diagrams looks interesting, I don’t need either. Their “Essential WPF Control set” is underwhelming, especially when compared against Actipro’s WPFStudio which is great and also comes with themes. So while they have offered me a free license to any of their other tools for blogging about them, I just don’t need any of them. I just wanted to blog about them anyway because LightSpeed is cool. 🙂
Your free Mindscape license
If you’d like the free license that Mindscape has offered, drop a comment below, I’d love to hear from you about what you’re currently using for persistence (if anything) and why you want to try something different.
Speed: For object database sceptics, in my tests, the object database Eloquera was just as fast as the LightSpeed over SQL-Server combination, and LightSpeed is very fast. Micro benchmarks never tell you about real-life, but my little test was a multi-threaded test with multiple instance types and inserting and updating hundreds of thousands of entities. The guys over at Eloquera are also doing a great job.
Licensing: With Eloquera’s new licencing model I’ll probably be switching my own project over to Eloquera when they get LINQ support, because DB4O’s draconian royalty based licensing is cruel and unusual punishment for a small business struggling to get started. (And sadly the .NET version of NeoDatis has completely stalled, although if I start making cash I’m tempted to donate some to the NeoDatis guys to see if we can’t get it going again).