The Seven Layer Cake of Web Development


Modern web development (especially for businesses) can be quite challenging and exciting! But to build a scalable  and maintainable complex web application can be a challenge. Lo and behold that it can be as simple as making a seven layer cake (yes, I know the picture has six layers, but stick with me).

Persistent Storage Layer

These days pretty much everything in a website is dictated by or stored in a persistent data storage device (SQL, NoSql, File, etc…) and the data within ranges from simple key-value pairs to (in some cases) entire web pages. It’s an important aspect of web development and shouldn’t be overlooked and glossed over.


Choose a relational database management system (T-SQL, MySQL, etc…) when you have data that needs to be related but stored separately. This is the first (and only) stop for many folks since there is a lot of expertise in the field available and RDBMS’s are pretty easily understood. Additionally there are some great tools for managing them, and the ones that are out there are generally well-supported and mature products.


Use NoSql when you require speed and simplicity. There are a tremendous number of these and they vary from simple key-value engines that run in memory with a persistent backing such as Redis to document stores like MongoDB to almost RDBMS offerings like Cassandra. Check out the Wikipedia article for more information on what’s out there.

Object Model / Data Abstraction Layer

Although many would argue against an object model, having some layer that abstracts the model of the database away from the actual usage of it is extremely useful later in the product life cycle if you discover that your chosen persistent storage provider is unable to keep up with your exploding business! Keep this layer thin and you’ll rarely need to touch it, and later if you need to swap it out you can do so quickly.

Data abstraction is another “nice to have” the idea being to keep your work atomic (simple calls that have reliable results) which can be pieced together by your business logic or controller to have the desired effect.

Business Logic Layer

Some web sites choose to combine the business logic layer with the controller which can be a mistake that later leads to large files full of spaghetti code. The business logic layer is the one that “the suits” care about the most, here is where they will tweak the rules and make crazy changes. Keep those crazy changes away from the rest of your code and you will be a very happy person.

Controller Layer

This is where it all comes together, the business logic layer uses data provided by the ORM / DAL (which in turn gets its data from the persistent storage) to deliver data to a hungry view layer. At this point it becomes easy to see how building these layers nice and separate from each other reduces code, bugs, and time spent debugging.

View Layer

In the view layer all the structure of how the data is displayed is defined. Remember to keep this layer mostly free of code, you are focusing on one thing here: interacting with the user. Ask yourself this question: “does what I’m writing affect the user’s experience with my application?” Does it have to do with colors, boxes, lines, pictures? That’s the view layer! Does it have to do with how something is stored in a database? Wrong spot! There’s some ambiguity when thinking about input validation, the simple rule is: do input validation as best you can, but if it degrades the user experience then change your approach!

Presentation Layer

The presentation layer is all about how everything comes together, the visual appeal of your software and how it interacts with the user. This is distinct from the view layer because there is no code here at all. That’s right, no HTML CSS JS or any other letters put together. How does it look, feel, smell, taste, whatever you are trying to present to the user give it good attention because I’m sure Myspace had some great code behind it, but it was severely lacking in presentation.

 Client Layer

Okay, we’re back from touch-y feel-y presentation layer back to hard code. The client layer is the stuff that’s running on the actual client machine. We’re talking HTTP headers, cookies, JavaScript, ajax, the works! Many modern browsers like Google Chrome will actually analyse your page and give advise on how to better optimize the client experience.  This includes potentially using a static content server to serve out files that rarely change (JavaScript, CSS, etc…) and handling cookies correctly. The client layer is big and stretches from network performance to JavaScript optimization to CSS fixes for the major browsers and which version they are at. Do not underestimate this as a layer and consider  methods for segregating it from the view layer both during development and deployment.

Have Fun!

In conclusion web development when done correctly can be a tremendous amount of fun, so enjoy yourself! Remember that there are many paths to the same end, but some planning ahead of time can really make you life much easier!

Leave a Reply