Thursday, June 11, 2009

Revamping Existing Sites

When people consider updating their websites, the first consideration is often design - rightly so since that is what is likely to attract customers. However I would argue that maintainability and extensibility are equally important. Asking questions such as the following should provide a good indication of where your site stands in this regard.

How difficult is it to:
  • Add content
  • Re-arrange pages
  • Change navigation
  • Add dynamic elements (authentication, Web 2.0 features, CMS etc)
  • Control access to resources based on who is logged in

The key factors in maintainability are separation of style, content and business logic and avoiding duplication within any of these areas. Thus, all content should be structured (that is what XHTML is for) in a way that makes sense for that content. Styling should be achieved through external style-sheets and templates should be used to avoid repetition. Extensibility is often best achieved through some form of dynamic back-end. This facilitates moves adds and changes with a minimum of fuss and allows for business logic to be injected into the page load process.

Often, I'll be called upon to add functionality to an existing site. Sometimes, this is a straightforward task, frequently made easier by leveraging an existing loosely coupled framework such as the Zend Framework. However when the desired features are more extensive either in complexity or quantity, the task becomes inefficient due to the fact that the preexisting code base does not adhere to the principals I listed earlier.

Putting this all together, an approach I have taken recently when faced with refactoring an existing site is to convert the site to run through a web application framework. Zend Framework 1.8 has greatly simplified this process with the maturing of Zend_Tool and introduction of Zend_Application and Zend_Navigation. My approach is basically as follows:
  • Create a Zend_Application project using Zend_Tool
  • Build the controllers, actions, view script stubs etc. using Zend_Tool
  • Create a navigation xml file reflecting the site structure
  • Create the necessary layouts and common elements
  • Work through each page, converting it to clean semantec XHTML and build complementary styles along the way.

While working through this with the client, they will often identify significant parts of the site that can either be discarded of need to be re-written from scratch. Thus the HTML cleaning exercise becomes less arduous.

0 comments: