The Home of Joe Lucas
November 15th, 2007

It’s a well known fact in the analytics industry, good site design is crucial to site performance. What’s not a well known fact is what constitutes good site design. One thing I deal with on a daily basis is poor design decisions from the ground up. This means that along with all of the other design tips you should adhere to (unique page titles, smart navigation, css, etc.), you should be building sites with strong coding techniques. This article is going to cover some basic tips that I feel should be implemented behind the scenes to assist with overall site performance, lower costs, and improve ROI.

Choose your platform correctly

How important is your site’s platform to its overall performance? In my opinion, it’s critical. Your platform choices include your server architecture, your programming language, and your backend data choices. You’ll want to evaluate a few things here. First, is overall site performance, meaning you want your pages to load as quickly as possible. So, faster servers and optimized code are key here. If your data and content are stored in a database, you’ll want to pay special attention to your database structure. If you are loading content directly from a database on every page, you’ll want to think about how the content is laid out in your database. Picking the right table layout and key indices can really improve performance. Speed boosts can also come with picking the right table type. If we take the example of a MySQL database, for instance, there are a few different table types that you can choose. This can affect overall performance of the database depending on which you select as well as how much overhead that table type brings to the database itself. Understanding how the data flows from your database to your page will allow you to have better database architecture and really improve performance.

You’ll also want to choose your scripting language carefully. If you decide a PHP/Linux server set up, is that really going to allow you to do what you want with the site? Would your overall goals be better achieved on a Java platform? Look at your development resources as well as the type of content you wish to publish. Ajax and Flash are also important considerations, however, that should be left for another conversation entirely.

Object Oriented Design is your Friend

Most web languages now support some type of object oriented design. If you have this option you should use it. Maintaining your site and pushing updates will be so much easier if you utilize an object oriented backend. In the past, it’s been commonplace to rely on file includes and a template design. This worked and is a decent option to achieve an object oriented like approach. Let’s take a look at how this can improve the maintenance of you site. Consider the following example written in PHP:

<?
include “/header.php”;
$html=”Some Page content Here”;
print $html;
include “/footer.php”;
?>

That seemed simple enough. I’ve got a common header file and a common footer file. So, if I needed to make any updates to my footer or header I can easily do it in one file and have the changes propagate live throughout the site. Perhaps we can do something similar and have a common navigation include which will allow us to do the same thing. So, the code would now become this:

<?
include “/header.php”;
include “/navigation.php”;
$html=”Some Page content Here”;
print $html;
include “/footer.php”;
?>

Seems harmless enough, right? That code should be fairly maintainable and still allows a good degree of customization. This is probably the easiest way of building a large site in PHP, however it’s hardly the most useful. Some limitations to this code would be the concept of a unique page title. Well, in order to get that, we either need to give up the header include and hard code the header information into each page (not so appealing), or we could make the code more complex in order to make a dynamic page title. Another drawback to this approach is if we wanted to add content to the page after deployment. Perhaps we wanted to change the layout of the page slightly and introduce a right column that would display advertisements. In order to do this, we would now need to edit possibly hundreds of pages in order to make this change. This is a pretty monotonous and time consuming task and in my opinion, a complete waste of time. By deploying an object oriented approach to the site, we can overcome these obstacles while still maintaining a template-like design. Let’s revisit this example using an object oriented approach.

<?
include “/page.php”;
$page=new page();
print $page->createPage(”Page Title”, “PageID”);
?>

Example of page.php:

<?
class page{
function createPage($title, $id){
$html=”<html><head><title>$title</title></head><body><p>Page ID: $id</p></body></html>”;
return $html;
}
}
?>

Optimizing your Code

Another great way to improve overall performance is to optimize your code. If you’re pulling content from a database, are you using the right SQL query, or are you pulling a lot more information from the database and then going through everything to pull just the content you need? Are you closing your database connections after running your query? Do you have a lot of whitespace in your code that inflates the file size that the server has to deal with? Can you accomplish in 5 lines what you’re doing in 10? I’ve certainly been guilty of all of these in the past. Writing good code is hard on the first pass. After you’ve deployed, go back through your code and see where you can make improvements. This is a concept called code refactoring and is very important to ensuring that any code you run on your site is as optimized as it’s going to get.

This is just the tip of the iceberg as to what you can do to improve overall site performance. Building a web site correctly from the ground up will impact every decision you will make for the lifetime of that site. Making the right choices early on will save money and improve the overall financial performance of the site, and isn’t that one of the goals for any analytics implementation?

We’ve succeeded in doing two things. One, shortening our code that initializes each page (shortened code means lower file size, which means less data for the server to deal with). We’ve also created one access point for updates. Now, no matter what needs to be done to the overall page layout on your site, you only have one place to go to make changes and push them live. You can pass in custom content, or in the above example, just a page id which could be used to grab content from a database and put into our page. We’ve also then succeeded in being able to have a template design for easy maintenance, as well as preserving a unique aspect of each page.

Comments
You can leave a response, or trackback from your own site.

Leave a Reply

Retweeting @arstechnica: Rumor: AT&T may finally announce iPhone tethering this week - http://ping.fm/6KG1m
Jan 5 at 10:21 AM

Pages
Sections
New Comments
    Blogroll