May 8th 2006 / taught
Something I take very seriously when it comes to web development and design is the precept of doing something once, and using it over and over. I call this “write once, use twice”. In reality I’ll use it more than twice; it just sounds better than “write once, use it thousands of times”. This theory can be put into practice in every aspect of developing for the web—or even running your business.
In CSS
When I write CSS, I do it differently than most developers; I use a logical and ordered format that I have developed over time. I have a framework I created called “CSS467″ (it’s named for a specific scene in a movie I love). Within this “framework” I have CSS classes that control specific things, which allow me to keep my overall CSS slim, but still have flexibility and control over the non-specifics.
For instance, I have a class named “shaft”, and another named “shift” the former contains the rule “float: right;” and the latter has “float: left;” this is all these two classes do. This allows me to quickly float an image or paragraph or div without having to create a whole new class, or edit an existing class, it affords me control and flexibility.
There are exceptions to this, if I need to place floats on an unordered list to make a horizontal-image-rollover menu, I would apply the “float: left;” in the CSS rule for the “li”, as this is easier to control and change later—not to mention cleaner—than applying class=”shift” to each “li”.
I have an entire series of framework classes that allow me to add properties/rules to certain elements without having to create a whole new class or edit an existing one with potentially redundant information.
In PHP
The concept of using a server side programming language to build web-sites is to make things easier to create and maintain, in my opinion PHP does this beautifully.
I have a function I wrote for use in OnePanel 1.5 (that will be built into OP 2), which builds any kind of menu you need from an array. It returns the menu using an xHTML unordered list, which can be endlessly styled using CSS.
The function allows me to build consistent and unique menus for my web-site projects without having to type out each menu, and then have to find and change each one if I make a minor change to structure, presentation or data. Menu_create() allows me the flexibility of individually styled CSS menus, without the overbearing hassle of site-wide code maintenance. And because all the values for the menu are stored in an array, it’s easier to read and change later. It allows me to go to exactly one place to change the structure of all my menus site-wide, and one other place to change the presentation and one other to change the data/content. This is true separation of content, structure and presentation, which makes my life and job much, much easier.
In Graphics
Photoshop has actions which allow us to do something once, and then apply it many more times without having to physically repeat each step. There is also the ability to create textures, shapes, brushes, patterns and styles that can be used—or overly used—without having to recreate them each time.
In Business
For me having templates for everything I send out; e-mails, contracts, letters, invoices etc… All I have to do is fill out the pertinent client information and click send. This saves me loads of time that I would be spending drafting every e-mail from scratch every time.
In conclusion, doing something one time, then re-using it is maybe one of the most powerful, flexible, consistent and overlooked ways to accomplish your daily development duties.
I hope I’ve given you some ideas and helpful solutions to help decrease the daily workload.