Wednesday, October 22, 2008

I Suppose You Could Do It That Way

So if someone asked you to write a thing that showed three items in a list loaded from a database, on each page in the application, would you:

A) load the items from the database each time and display them using a simple php for loop?
B) do something a little more complex like loading the data once per session, or per key id, and storing it in the app scope
C) get really crazy and use memcached or something like that


D) create a nightly CRON job that loads all the possible permutations of data by key id, then write a monolithic XML file, then each time the page loads, read that XML file from disk, using XPath to track down the values to show in the page

Take a wild guess what I just refactored. Hint: it wasn't A, B, or C.