Thursday, April 7, 2011

Raven DB & ASP.NET MVC routing

I've experimented a little with Raven DB, and have done some integration with ASP.NET MVC 3 (cause it's so easy to get things started).

The first problem I came up against was the default way that RavenDB stores the object keys :
profiles / 3074 (Profiles)
This presents a problem when you want to work with the MVC routing, which uses the '/' symbol in the routing - {controller}/{action}/{id}.
public ActionResult Edit(string id)
MVC interprets this as wanting to send the id (id e.g. 3074) to the action (object e.g. profiles). Instead, we want to pass the whole string (profiles/3074) as the id to the controller action (Edit).

To start, we need to change the type of id to string, as it defaults to int. Secondly, we need to change the format of the object key - there are other ways of attacking this problem, but I found changing the default separator from '/' to '-', this happens when you initialize the document store shown below
var documentStore = new DocumentStore { Url = "http://localhost:8080/" };
documentStore.Initialize();
documentStore.Conventions.IdentityPartsSeparator = "-";
We end up with documents in our store looking like this, and passing through to the correct controller!
profiles-6146 (Profiles)


Tuesday, April 5, 2011

Stand up


Danielle on my Desk
Originally uploaded by riebschlager
A couple of weeks ago I experimented with a standing desk, which meant dragging my monitors onto a shelf, putting my keyboard up higher and generally shuffling my desk about. It wasn't to be a permanent solution, but more to see if I thought it would be worth getting a permanent setup.

The first couple of days were pretty painful, it's been a while since I've stood up all day, but after a weekend I was feeling good. I felt like I had a lot more focus and didn't waste as much time on facebook and twitter, which was nice to feel that I was getting more done. I think it's also great for programmers, as pair programming would work well as opposed to having a corner sitting desk (which is what I currently work at), allowing better access to swap the keyboard and improved screen visibility.

Unfortunately my wrists weren't a big fan of the awkward position that I'd placed my keyboard in - without a solid desk to rest on they just started to flare up. So, I'm back sitting down waiting for my wrists to recover, and hopefully get my desk setup properly.

If you're interested in standing desks, Lifehacker is a great place to check out to start with.

Do you have a non-standard workplace? How did you make it happen? Does your workplace encourage you to work in a way that helps you work best, or do they want you to just sit there and stick to the standard way of doing things?