The .NET eco-system is a great place to begin your personal ventures: Part 2 — Fast and free persistence

I recently started to build an application that I have wanted for a long time (www.mylifelessons.net). It is built and hosted using facilities provided by the .NET eco-system, which I have found to be brilliant for rapid development — with almost no initial cost

My application might not be used by anyone other than myself, but my experience shows that all you need is effort and motivation to get your ideas up and running so you can gauge user feedback. The .NET eco-system has the rest well taken care of.

This series of posts will contain:

Part 1 — Web frameworks and hosting — FubuMVC and Windows Azure

Part 2 — Fast and free persistence with RavenDb/RavenHQ

Part 3 — Easy styling with Twitter Bootstrap

Part 4 — Background jobs with Azure worker roles

Fast and Free Persistence

You’ve got a walking skeleton out there in a live environment with a 3 word deployment procedure (git push azure), but now you need to flesh out that skeleton and give it a bit of a pulse.



You want to bring it to life by having data-driven scenarios. And… you want it free (to begin with). Easy!



For www.mylifelessons.net I chose RavenDB because it makes development easy and fast (I’ll show you how shortly). I chose RavenHQ as a host because that’s also easy — plus it costs nothing to get up and running in production.



Check out the recipe at the bottom — try it for yourself (follow on from part 1).

RavenDB for Rapid Testing

A comprehensive set of unit tests is not needed when you have a thin application and your persistence provider is as fast as string concatenation. With RavenDB’s in-memory embedded store you get exactly that.



My testing strategy was thus full stack context specifications (BDD-style-kind-of-whatever) focusing on my applications behaviours (not the components). Here’s an example:



https://gist.github.com/4184443.js



https://gist.github.com/4184455.js



My feedback is still as fast as unit tests because the application is so thin. But now I can refactor a lot faster — particularly when the interface between two components changes. Importantly, I’m getting the same value but with a lot less tests.

RavenDB for rapid development

Imagine all the benefits of an ORM without having to mess about with ORM problems and mappings to SQL. Sounds like a dream, but that’s exactly how I find working with RavenDB — you feel like you’ve only done half the job.



RavenDB has a client that has been thoroughly thought out for .NET development. If you know NHIbernate’s ISession you know RavenDB’s client. IMO this makes it preferable to other document databases.



Here’s an example of persisting a few records and querying others — yes that LINQ provider is insanely beautiful, with its potential for constructing dangerous SQL in the background viciously castrated.



https://gist.github.com/4184509.js



https://gist.github.com/4184996.js



Ok, now repeat after me ten times — “there is no SQL mapping and debugging, there is no….”

Now I want to deploy — easy peasy with RavenHQ

As you know and love with your SQL solutions, changing environments requires a change in connection string. And that’s exactly how RavenHQ works.



All you need to do is sign up and create a free database (upto 15mb storage). This gives you a connection string and an API key that you set on your document store like this:



https://gist.github.com/4185003.js



This is really easy, and incredibly fast to set up and start using.



Once your db is configured, RavenHQ gives you a url to login to the management studio — another usability dream.

Recipe

1. Install the raven nugets (server, embedded and client)



2. Add your testing infrastructure (something like this)



3. Churn out some code



4. Create an account and a free database at RavenHQ



5. Copy connection string from RavenHQ onto your local configuration



6. git push azure (deploy)

Get lost you fan boy

Call me a fan boy if you like and I’m happy to sound that way. But when you spend some time with RavenDB you will probably be one too — especially when you are creating your own applications, funded by your own spare time and bank account.



RavenDB and RavenHQ are simple to use and let you get your job done rapidly.

--

--

Nick Tune
Strategy, Architecture, Continuous Delivery, and DDD

Principal Consultant @ Empathy Software and author of Architecture Modernization (Manning)