Building a website: It’s all the little things

Developers always have an overly-optimistic view of how long something will take to code. Faced with a question of, “How long will it take to build a website that does X” the answer is more often that not, “Pffff, that’s easy, nothing complicated, two weeks”.

Yeah…….right.

Jeff Atwood wrote about this a while back after people were claiming that they could clone Stack Overflow in a weekend. His post talked about getting the user experience right as well as getting the code right.

I’ve been working on a new site over the last 6 weeks or so. It’s my first web app as such, everything I’ve built before is really just content delivery.

Of the 6 weeks I’ve spent on it – not full time, a couple of hours here and there in the evenings – a big percentage of my time has been spent doing non-coding stuff and coding around getting the user experience right. Getting the actual application bits of the site right was the quick part – all the stuff around it is what took the time.

It’s been an eye opener as to all the little things that are needed to get an app out into the wild:

  1. Buy or find a CSS/HTML theme.
  2. Buy a logo
  3. Find hosting
  4. Set up hosting
  5. Set up components on hosting (PHP, database, Apache, caches, directories, users, etc)
  6. Test on all supported browsers
  7. Secure code and server
  8. Security test
  9. Test failure of components (mainly DB gone away)
  10. Functional testing
  11. Deployment
  12. Tweak CSS/HTML/Javascript for browser compatibility
  13. Minify JS and CSS
  14. Create other graphics, screen shots
  15. Test performance
  16. Get Beta test feedback
  17. Marketing/PR

Create shortcut to a website using Ubiquity

You can add shortcuts into Ubiquity to make it easy to get to your favourite sites – for example, I just type SO to get to Stackoverflow.com.

  1. Open Ubiquity and type help
  2. On the help page go to the Hack Ubiquity menu option
  3. Paste the Javascript snippet below into the textarea – no need to save, it’s automatic
  4. Amend the name to be your shortcut and obviously the URL too

CmdUtils.makeSearchCommand({
name: “so”,
url: “www.stackoverflow.com”,
});

Ubiquity command for looking up PHP functions

I’ve added the following to my Ubiquity config to easily look up PHP functions:

CmdUtils.makeSearchCommand({
name: “php”,
url: “http://uk3.php.net/manual/en/function.{QUERY}.php”,
});

To add this to your Ubiquity setup:

  1. Open Ubiquity and type help
  2. On the help page go to the “Hack Ubiquity” menu option
  3. Paste the above Javascript snippet into the textarea – no need to save, it’s automatic
  4. Open Ubiquity again and type php urlencode and you’ll be taken to that function’s page

Customers don’t know what they want

If there’s one thing every programmer needs to have injected into their head, it’s this: Customers Don’t Know What They Want. Stop Expecting Customers to Know What They Want. It’s just never going to happen. Get over it.

Instead, assume that you’re going to have to build something anyway, and the customer is going to have to like it, but they’re going to be a little bit surprised. YOU have to do the research. YOU have to figure out a design that solves the problem that the customer has in a pleasing way.

Put yourself in their shoes. Imagine that you’ve just made $100,000,000 selling your company to Yahoo!, and you’ve decided that it’s about time to renovate your kitchen. So you hire an expert architect with instructions to make it “as cool as Will and Grace’s Kitchen.” You have no idea how to accomplish this. You don’t know that you want a Viking stove and a Subzero refrigerator — these are not words in your vocabulary. You want the architect to do something good, that’s why you hired him.

From Joel On Software and slightly modified.

Tweeting with PHP

Fabien Potencier with an excellent code snippet for posting to Twitter without using any third-party code or libraries.

http://fabien.potencier.org/article/20/tweeting-from-php

Twig – The flexible, fast, and secure template language for PHP

Sensio Labs (the Symfony creators) have released a new PHP templating engine.

Why would they bother when there are already a load of templating engines out there? For a few reasons:

  • It’s super fast
  • It has a very concise syntax
  • It has either automatic or user-specified escaping of output variables

I’ve been using Smarty up to now. It’s mostly been great but I’ve been bitten a few times by it’s sometimes difficult looping syntax, I’ve sometimes had to re-structure arrays in my controllers to get Smarty to iterate them properly.

I’m defintely going try Twig out on my next project – I may even convert my current project to use it (cos, you know, there isn’t a ton of stuff to do on it anyway). Plus, it’ll no doubt be in Symfony very soon and so will get a lot of testing and support.

Fabien Potencier writes an interesting article about PHP templating engines and says why he doesn’t consider PHP itself to be a templating language – it’s too verbose. Up until reading that I was thinking of dropping Smarty and just using plain old PHP but he’s points made me realise that would be a bad idea. So, Twig it is.

The Twig website.

Radiopaedia Releases Practice Application for The iPhone

436534gopRadiopaedia.org, a Wiki for radiologists, has released a teaching file for the iPhone. The app contains a collection of cases to prepare for exams or simply to use as a refresher in clinical work.

Here’s a screencast showing the features of the app:

Product page: Radiology Teaching file…

xkcd: volume 0 now available!

The greatest comic in the history of the Internets is now available in print from the XKCD store. Are you still reading this? Get the hell to the store, like, now.

fight

How to avoid the cannot modify header info – headers already sent problem in PHP

I got hit by the “headers already sent” problem again the other week. I tend to dip in and out of PHP and I keep forgetting the cause of the problem.

The way to avoid this error is to not include the closing ?> tag in PHP files that only contain code.

This is an recommendation from Zend. That Zend page says, “For files that contain only PHP code, the closing tag (“?>”) is never permitted. It is not required by PHP, and omitting it´ prevents the accidental injection of trailing white space into the response.

CakePHP – Warning (2): Cannot modify header information

I going through Cake’s 15min Blog Tutorial (again) and I hit a problem after I’d added the add and delete functions to the controller.

My list of blog posts displays fine, clicking on the “Add Post” link from the index works fine – but when I submit the add form I get the following warning:

Warning (2): Cannot modify header information - headers already sent by (output started at /var/www/cake/app/models/post.php:9) [CORE/cake/libs/controller/controller.php, line 644]

I was getting this when I tried to delete a post too.

Turns out that there was extra whitespace after the ?> closing PHP element in my post.php – removing it fixed the problem.

UPDATE: I’ve found a solution to this problem.