Text

CRUDE: CRUD+Execute Operations

If you’re a developer, you undoubtedly know what the CRUD operations are: Create, Read, Update and Delete.  These are the basic operations of persistent storage.  They are also the basic operations you should adhere to when developing an MVC web application or web site.  It will help you keep your MVC structure simple and clean.  Developing with ASP.NET MVC3, Visual Studio has built in templates that stub in the CRUD operations for you.

However, these operations don’t always meet the need for the controller action.  Sometimes you need to actually execute a command.  Perhaps you’ve built an web frontend to a server and you’re providing the user with a way to shutdown or restart the server through said frontend.  Or maybe you need to transmit a message over a communication network.  In other words, perform an operation that doesn’t really interact with persistent storage or is a complex series of steps to complete that operation.

I was surprised when I did a Google search for “create read update delete execute”, the only results I found about it on the first page were definitions for the CRUDE acronym.  The rest were about CRUD.  I understand that these operations are typically referencing persistent storage, but with the popularity of MVC over the past few years, I’m surprised we haven’t seen more people extending these for operations to include Execute.

The take away is, when you’re building your MVC controller, try to stick to the CRUD operations, and when you have to move beyond them, ask yourself if you’re organizing your controllers and actions incorrectly and then ask yourself if the operation actually falls under the “execute” umbrella.  It may help you structure your controller actions better.