This project is read-only.
Code Contract

Anything that can go wrong, will go wrong. -- Murphy's law

When deploying my site to FaceBook, I've got a surprise. What could have been wrong with showing the default page?


It turns out FaceBook does a POST not GET to /. And my routing did not handle POST to /. Lesson learnt, we always have to be defensive.

Good news is that Rabbit Framework's assert functions are there ready for defensive programming. We can use them to define code contracts, preconditions, post conditions and object invariants. Why not?

@inherits CrudController
    Layout = SiteEngine.RunHook("get_layout"as string;
    Assert.IsTrue(Page.View != null"View has not been set.");
    Assert.IsTrue(Page.Model != null"Model has not been set.");
@RenderPage(Page.View, Page.Model)

Last edited Mar 9, 2011 at 9:02 PM by yysun, version 2


No comments yet.