The case for PORV (Plain Old Razor Views)

At the turn of the century there was a battle for where and how to store your applications business logic. Entity Beans became the bloody loser. Plain Old Java Objects came away victorious.

The benefits worked both ways. It became easy to change your infrastructure without effecting the business logic. Or in faster moving businesses developers could evolve the business logic without concerning themselves with the infrastructure supporting the application.

When I look at ASP.NET MVC I see Razor templates littered with details about the infrastructure. Surely the responsibility of the View is to tie together the HTML, styles, scripts and images to create the visual aspects of the user experience? Developers want to be concerned with browser and device compatibility. Beyond the basic model interface they should know nothing about how the routing is implemented, how the controllers are structured, which actions to call etc.

The case for PORVs is clear. You can test all the visual aspects of your application without a database or more complex content management system. You can work directly on the views without the need to build/deploy to a central application framework. Your visual tests don’t break every time the database is updated. You can implement a separate deployment process taking visual changes into production using a light-weight fit-for-purpose process. You can use the same visual code across multiple applications.

The main villain of the piece is the static HtmlHelper classes. If the PORV idea is to work then this approach needs to change. Perhaps any infrastructure specific logic can be shifted into a View Model or more open Helper interfaces can be used with DI making it easy to switch the infrastructure service? I certainly don’t have all the answers. I spend too little time coding these days to explore these ideas fully. All I can do is put the idea out there. So please feel free to comment.

One final note. Martin Fowler and co. recognized the need for a fancy name. So is it Plain Old Razor Views, Plain Old Razor Templates or something else?


This entry was posted in Sitecore. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s