Reusable Code

Zen
Photo by Buddha327

It is often said that good coders write code from scratch and that great coders reuse code. If that’s the case then it appears I’m a great coder. I have about 4 or 5 different xHTML/CSS layouts which I am constantly reusing because they are just solid, cross browser layouts which can be modified and tweaked to suit most designs.

Most designs follow similar principles; a header, 2 or 3 columns and a footer. Therefore there really is no need to reinvent the wheel. As well as being time-saving, it is also a matter of consistency and ensuring that the quality and backwards compatibility is built into the templates.

This ability to manipulate templates really comes down to separating content from style and harnessing the power of CSS. Being able to keep underlying xHTML code exactly the same, and to change the design through just CSS is something that even today, some designers can’t grasp. All too often I see in-line styles where it’s not necessary and this makes updating a site very laborious, tedious and time consuming.

To see what I’m getting at, a great project by Dave Shea called CSS Zen Garden was started to really flex the muscles of CSS. Although this project is relatively prehistoric in Internet terms, it still attracts a lot of attention. This is how the web should be built, with semantics and accessibility in mind, however there are far too many Web Design companies that just don’t care about the ethics of the work they do, just so long as they get paid.

What is valid anyway?

Coding Perfection
Photo by Simon Pow

There are many people that talk about xHTML and CSS code with a passion (myself included), and that only perfectly valid code is the way to build a website. If you want my honest opinion, the only reason my code is always valid is to shut up the critics that only base critiques on whether it passes the nice Validator Test over at W3C.

On the odd occasion, the Validator can be a good way to spot a mistake, but in no way does it guarantee cross browser compatibility or in fact make it work in future browsers. In fact, more often than not, perfectly valid code will never be cross-browser compatible, and that is the most frustrating part of what I do. What is the point then in having these standards? At the end of the day, a website user doesn’t care how a website works, so long as it works for them!

I guess it just comes down to some people’s mantra, or work ethics. When I create the code I do, I firstly ensure that it is cross-browser compatible (for the consumer), and once I have succeeded I then start to work on ensuring that the code is also valid (for my ego). Obviously the consumer comes first, but as the perfectionist I am, standards are imperative. It also shuts those small-minded critics up!

To me, what is far more important is the accessibility and usability of a website. There are people that like to think that valid code means these two things, and they couldn’t be more wrong. Semantics and logic are the key to these issues, which is something I’ll be talking about in the not too distant future!