Since 3 weeks we’ve got a new colleague at work: Rob. Rob is a very skilled (ASP).NET (senior) developer and we’re introducing him to the world of Content Management. So far he hasn’t worked with a predefined system as Sitecore is. And everytime someone like Rob joins your team, you’ll have new exciting discussion about implementations.
One of the discussion I’ve had was all about data integrity. Where do you want to check that a user just has selected 6 items for displaying? And not, as they often do, select 8, contact our support-team why the last 2 items aren’t displayed.
In Robs opinion, you should check it on 1 sides: CMS and not on the front-end. And while writing this entry, I’m still 100% not sure wether he’s right or not. Let me explain you why:
First of all, for the visitor, only 6 links should be showed. You’ve to make sure you don’t allow more, but for far can you go with trusting your content editors? Should you actually limit them? Is that recommended? Wouldn’t such a ‘hook’ be the end of the flexibility in the system? Is such logic allowed in your data-tier? Or in your presentation logic?
In any case:
- I don’t want more items then allowed to be stored in my database
- I don’t want to write extremely inflexible(and ofcourse also flexible) ‘codes’ like regex’s which are interpretated on runtime instead of compile time
- I don’t want any logic in my front-end on limiting data
- I definitely don’t want to confuse the CMS user
The requirements implicate that the validation can’t be done at the final (presentation) tier. The user shouldn’t be set on the wrong path, so the data he saves shouldn’t be presented on their front-end on another way as it’s represented in the CMS-client. But the default Sitecore validation does not match the requirements. Why not? Well it’s executed at runtime, so for example I’m never able to check if all IDs exists within Sitecore. Or if the match may be made(folders-items together with data-items, etc).
Therefor I’m definitelly happy with the new functionality within Sitecore 5.3.1 :). As the validation can be done direct in Sitecore, it’s validated on runtime, but not intrepreted on runtime(which is actually the requirement).
But, what to do when your logic is incorrect? And side-effects? Such an incomplete indexes? In those cases you want to be sure that your website is displayed correct. Shouldn’t you create a ‘failback’ in your presentation code? Therefor, I’m still a bit doubting…