Do It Hard, Do It Once: Part 1
Posted on 2007-09-13 (Updated on 2019-01-22)
I'm a hardcore web guy. I dive straight into the mucky muck of tags and CSS and server stuff and I love it that way. I code each piece of HTML or CSS in a page by hand. I use two tools when doing web work: The GIMP for all my image needs, and PSPad for absolutely everything else, and with these tools I manage two highly complicated web sites. At last check, they have over 700 documents (pages, downloadable documents like PDFs) between them.
Managing this much content incorrectly is a good way to become an alcoholic. Unfortunately, I've never been a big drinker, so I have to create techniques that allow me to manage this much stuff without losing my mind. That, in essence, is what this whole entry is about.
Templating
Do you have a navigation bar that is common across several pages? Redundant elements that can be reused? Need to make site-wide changes without a ton of work? Then templating is for you. Templating is the single easiest way to make web sites more manageable, by grouping together reusable pieces of the page (like navigation) and using server side scripting languages to include them when needed. This not only makes it easier and faster to build pages, but it makes it much easier to maintain these elements across the site. The more code you reuse, the less you have to rewrite.
Separation of Presentation, Content, and Behavior
In the early days of the web, there was one file: index.htm, which held the entire web site content. When methods of embedding images came along, there was the index and the image files. As web sites started to grow, more and more technologies came along to allow the separation of different elements in a page. Currently, we have the following to use:
- HTML for structure
- CSS for presentation
- Javascript for behavior
Keeping these elements of a page separated makes pages much more manageable. If all aspects of a page are mashed into one file, like old table-based layouts, editing a single piece of a page becomes a game of hide-and-seek. Separation of structure, presentation, and behavior make code more readable and organized and make navigating that code much faster. Organized code also lends itself much better to templating, which is a web guy's best friend.
This is an ongoing process, so I will post more as I go. Keep an eye out for updates!
Tags: content