Tuesday 27 October 2009

Trying to learn OO PHP

This morning I woke up at 4am, but couldn't get back to sleep. I got up at 6am, and after a shower etc. did more work geocoding the images from our recent holiday. Luckily there weren't quite so many images where I hadn't had the gps switched off (or the GPS just hadn't recorded a tracklog) compared to the other days, so there wasn't quite so much manual geocoding needing to be done. For one day I even managed to geo-code all images automatically from the tracklog - and some of the photos were in a subway station!

While getting that finished and the images backed up, I also went through some more of my emails. I've got my main inbox cleared out now. It seems that there was also a lot of work done on panachallenge while I was away, as I had about 200 emails to do with that, which were just all raising tickets, fixing them, then closing the tickets.

After that I did a bit of work on my photo website. At the moment I'm displaying the image's metadata in a table, but it was suggested that the metadata isn't really tabular data and it would be more semantically correct to place it in a definition list. So I tried to do that. While using a definition list does cut out quite a bit of markup - no <tr>s, <tbody>s, or <colgroup>s, I found that with the way I am displaying my table (percentage width cells with padding defined in pixel), I would need to add a <span> or similar inside each <dt> and <dd> to assign the pixel padding to to achieve the same effect.

So after about an hour or two of trying to get the definition list to display the same as a table, I gave up and reverted back to the table.

After lunch I put an order in for some Astra Zeneca shares. I feel the stock market is well overdue a correction, and that the share price of defensives will take a slide along with the rest of the market when it does correct. However, I may well be wrong, and with Money Morning tipping Pharma stocks, and a nice dividend, I thought I may as well take a punt. I've only put £1000 in, as that's all the cash I had in my shares ISA account. When I logged in to put a limit order for the shares, I also checked my current holdings, and my gold holdings have gone up from about £3000 - £4000 - so that's quite a nice profit so far. The problem with being an overly cautious investor like me (and not having much money to invest) is that you always wish you'd put a lot more money in when you see the percentage gains you've got.

I started reading a book about Object Orientated PHP, then it looked like it might get sunny so I cleaned my cameras and lenses, put the partitions back into my Lowepro Slingshot 300aw bag, and then put the D200 and lenses for it into the bag. I also vacuumed my room before doing this to try and minimise the dust.

By the time I'd done all that, it wasn't actually looking that sunny (it never actually got sunny, just looked like it was going to be), so I went in the back garden and took a few photos of some flowers (didn't seem to be any insects around). I came back inside and then read some more of the OO PHP book.

In part of the OO PHP book it was saying about type hinting in object methods. Unfortunately it seems PHP only currently implements type hinting for arrays and objects. Doing some googling, it seemed that type hinting for scalar values was unlikely to be included in PHP, with it being a loosely typed language, but I did find a patch to enable type hinting for scalar values in PHP. I think to apply the patch, you
  1. download and unzip the PHP source code
  2. in terminal cd /path/to/php/source
  3. in terminal patch -p0 < /path/to/type_hint_final.txt

I also read a thread saying that you should use interfaces instead of abstract classes. I'm not sure exactly how this would work though, since it seems you can't define methods or properties that would be shared across a bunch of classes using interfaces, whereas you can using an abstract class as a parent.

The weather was overcast (and quite windy) all day.

Food
Breakfast: Bowl of crunchy nut cornflakes; cup o' tea.
2nd Breakfast: Strawberry jam toast sandwich; Coffee.
3rd Breakfast: Kirsch and desert (custard) biscuit; Coffee.
Lunch: Mature cheddar cheese with iceberg lettuce sandwich; Clementine; Home-made Mince Pie; cup o' tea.
Dinner: Tagliatelle; Cheese sauce stuff; Green beans; bits of bacon; Ground black pepper. Pudding was a large choc chip cookie made from packet mix by Ben and Clare. Coffee.
Supper: Choc chip cookie; shortbread finger; hot cocoa.

No comments: