The final part of the port of the MVC Music Store to Raven is the administration section, implemented in StoreManagerController. I am going to show comparisons of all the methods where the port doesn’t offer anything new, and then focus on an interesting conceptual difference between the implementations.
Please note that the main reason that the Raven code is so much shorter is that I threw away the nonsensical error handling (or lack thereof).
Again, throwing away the error handling that isn’t made a lot of the difference in the code.
Now we get to an interesting difference. The old code will delete orders if they include the deleted album. Raven’s code does no such thing.
It is important to understand that there is no such thing as referential integrity in Raven (or document databases in general). This can be a plus or a minus, but in this case, we are turning that into a plus, because we can delete an album without losing orders. I don’t know about you, but I like the idea of keeping the orders around. :-)
A bit more formally, documents in Raven are independent, they aren’t affected by changes to other documents.
There are two more methods to discuss with regards to the StoreManagerController, but I’ll discuss them in my next post.