Ayende @ Rahien

It's a girl

The least evil choice

Originally posted at 11/27/2010

A while ago I had to make a decision regarding how to approach building the multi tenancy feature for RavenDB. Leaving aside the actual multi tenancy approach, we had an issue in how to allow access to it.

We have the following options for accessing the northwind database:

  • /northwind/docs - breaking change, obvious, less work
  • /docs?database=northwind - non breaking change, not so obvious, more work

What choice would you take?

If you know what is the choice I made for RavenDB, please don’t answer this post.

Comments

Tim
11/28/2010 10:37 AM by
Tim

Would take the pragmatic approach and choose /docs/northwind. This way it's still intuitive and from all the documents in the database the url states that the user is only interested in documents from a certain repository.

Disclaimer: I actually don't know any of the urls ravendb is using so this might not be possible.

artr
11/28/2010 10:40 AM by
artr

The answer is obvious (it is the first one), mainly because it was posted here by Ayende to make a point.

I didn't closely followed RavenDB evolution, but, by me, the second choice may introduce querying and maintenance problems (e.g. when using the same code for 2 tenants).

Frank Quednau
11/28/2010 11:40 AM by
Frank Quednau

Said it before, will say it again:

"Backwards compatibility will be the end of our civilization"

In that light, make your breaking change, it will be for the better.

Zach
11/28/2010 01:06 PM by
Zach

I think the first choice is the better one in the long run and since RavenDB is still very young it's totally acceptable that it's breaking. Early adopters should be prepared for some shake downs in the API as the developers try and iron out the details and future roadmap.

Joe
11/28/2010 02:38 PM by
Joe

I would think the first choice is the better with a default of going to the first database if one isn't specified.

This way only those people with multiple databases get the breaking changes and they'll be the ones asking the question of how to specify the database in the first place.

Can you add a debug warning message to suggest adding the database name to the url? This will guide developers to the correct design over time.

pb
11/28/2010 03:24 PM by
pb

Both, so can get benefit of simpler more obvious syntax without breaking existing users. Or, if you think you can get away with it without defections, #1.

Dru
11/28/2010 03:26 PM by
Dru

the first one!!!

Julien Letrouit
11/28/2010 03:41 PM by
Julien Letrouit

I would choose the first one, with the addition of a "default" database and the management of naming conflict for this default database (default db would not be allowed if it has documents which name correspond to the name of an other DB). That way, no breaking change.

Nick
11/28/2010 05:35 PM by
Nick

Well the second option discloses more information about your system and provides a potentially greater attack surface.

First option for me is preferable and likely to be more secure.

Bertrand Le Roy
11/28/2010 08:36 PM by
Bertrand Le Roy

Break it, it will be time-boxed evil, and long-term goodness. It's not as if you were in v4.0.

James Newton-King
11/28/2010 08:55 PM by
James Newton-King

Both with the first option as default.

I don't know the specifics but rewriting a URL doesn't seem like it would be that much extra work.

Tuna Toksoz
11/28/2010 11:15 PM by
Tuna Toksoz

I'd say "breaking change" as well. knowing your style for more than couple of years, it is something i believe you'd do. It is more intuitive from the end user point of view, even though it is a breaking change.

Scooletz
11/29/2010 07:38 AM by
Scooletz

Break it, break it, break it! The first one. The second is uglier, and staying with ungly, imo wrong API would cause future problems.

Comments have been closed on this topic.