On 9 Oct 2008, at 08:13, Peter Morris wrote:
> Ashley, why do you say that? > > I have been bitten by sql server enforced constraints before. > > I had a situation where the constraints where stopping things being > saved, but ruby was not catching the fact that > things had broken and so was reporting that the save happened. Caused > a real headache. Peter, If that's happening, it's a fault of the ORM - presumably ActiveRecord. If it's making the assumption that a save is successful that's a BUG, and bugs are not justifications of workarounds. I've been bitten far worse where lack of constraints has meant an apparently simple bulk data insert crippled an application, which could have been easily averted. (The business rule in this case was actually pretty stupid, but it was there, and it was not enforced in any way.) > Also, the mantra of DRY suggests that the constraints should be in one > place. That one place being the model code. DRY is a guideline and a goal, not a religion. Sometimes there is just no way of avoiding duplication, and in that case you've got to do your best to limit the cost and risk involved. As you demonstrated above, the ORM you are using is clearly NOT suitable for enforcing data integrity, which means you're exposed to data corruption issues later on. Deciding whether to (and to what extent to) duplicate model constraints in the database should be based on the two inherent sources of waste: the cost of maintaining the duplication, and the cost of (fixing) data integrity issues later on. It's a personal choice, but in many (if not most) applications the data is incomparably more valuable than the code that accesses it, and therefore, IMHO, demands respect. Just my opinion of course, and who am I to argue with DHH... Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NWRUG" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/nwrug-members?hl=en -~----------~----~----~----~------~----~------~--~---
