Does this sound familiar?
(You): Hi - we’ve got a website and have been selling products online for a few years - our web guy moved to Switzerland though and we need somebody to make some changes…
(New tecchie): Sure, I’ll look at it.
** three weeks later **
(New tecchie): Man, this site is so screwed up. Whoever wrote this had no idea what he was doing. In order to make any changes I’m going to have to rewrite 30 different pages. It’ll take two months and twenty-six thousand dollars.
(You): What are my alternatives?
(New tecchie): Rewrite the whole site. It’ll take two and half months and cost twenty-eight thousand dollars.
(You): All I need is one product added!
(New tecchie): Dude, you should have bought a Dell…
(You): What does that have to do with my website??!!
Buying a Dell actually has nothing to do with your website. (OK, it could…don’t get all technical on me…) But scalability has everything to do with your website.
There’s actually a very simple reason why the above conversation is quite common: the site that you started a few years ago has slowly grown and gotten more complicated. It is now miraculously held together by layers and layers of rules and code, and attempting to change one thing now is like trying to upgrade the middle section of the leaning tower of Pisa. The tower won’t fall down on its own, but don’t start making structural changes!
In order to avoid scenarios like this, I’ve been using a “three-tiered architecture” approach for years. With this approach, the overall structure of your website looks like this:

With this setup, the data (e.g., product and pricing information), is the foundation of everything. A great deal of flexibility can come in, if the business layer is constructed to properly feed the data to the user interface. Here’s what can result:
1. You decide to change your shipping calculations. Those changes are done in one (and only one!) section of code. The formula is changed in the business layer, and the database and the user interface remain untouched.
2. You decide to add a product. Records are added to the database, and the business rules that read from the database automatically pick up on the new changes and carry the data to the user interface. (Result: “Hey, there’s a new product. BUY! BUY! BUY!”)
3. You decide to change the look and feel of your site to reflect your company’s new branding. Brown becomes orange, graphics and logos change, and navigation gets an overhaul. Your search and shopping cart functionality stays exactly the same though, because your business rules have not changed.
Technologies and programming languages change every day (*sigh*), but principles like this need to be applied everywhere. Over the next several days, I’ll demonstrate how we employ these kinds of techniques to provide scalability and stability to our applications.
