Template engines

Today I started on a private project with one of my friends, where we are looking at creating a fitness and healthstyle website, and this time around I wanted to design a very robust, hack-safe website which will keep you going for a few years.

I’ve evaluated some of the FREE templating system available under the gnu licenses and found two in particular very interesting, namely:

1. patTemplate
2. Smarty

SO of course I did and went some reading about the different systems, and found an excellent tutorial/blog-entry that Havard Lindset wrote about patTemplate on DevArticles.com .

At the end of the day I selected Smarty, why I really don’t know, maybe because I got it to work the fastest and am now running a multi-theme, multi-language web interface with this engine.

Now just waiting for our first advertisers … mmm

Other interesting reads:

Zend and Templates
Template Engines

Commenting your code

I was just wondering about commenting of code lately, how do you guys comment your code.

When I started to program everybody always told me to comment almost every little step, like

// open file
fhandle = fopen() ;

// read line-per-line of the file until eof
while(!feof(fhandle)) {
}

Anyways, lately I’ve become lazy and just programmed as the thoughts came to me, but then my manager visited my desk one day and notified me to start commenting my code thoroughly.

Since then I respected my “elders” and started coding by first writing all the steps as comments

// open file
// if file not exist do this, otherwise continue
// read line
// analyze line
// if junk do nothing, if not junk handle with care

and then filling in all the “code”

// open file
fopen()
// if file not exist do this, otherwise continue
if(!fread)
// read line
freadln
// analyze line
// if junk do nothing, if not junk handle with care
if(read == junk) blablabla