Archive for the 'life' Category

It was my daughter Boann’s second birthday yesterday. We had a lot of friends and family visit. Thanks especially to my sister Tarynn and brother Michael and their families for making it all the way up from Dublin!

Boann and Jareth both had a great day, which is a big change from Jareth’s other birthday experiences! Jareth’s own second birthday was spent hiding from everyone. Boann is the exact opposite - loves to be the centre of attention.

The rain fell sporadically throughout the day, but that didn’t stop the kids from running around like mad things. After everything was done, Bronwyn spent a while sweeping grass trimmings out of the house.

That night was the first that Boann was to spend in her own room. Up until now, she slept in a bed in our room, and sometimes in our own bed.

We moved that bed into a new room and decided to try put her into the same routine that Jareth is in - every day, we put Jareth up to his room at 8pm. It doesn’t matter to us whether he goes to sleep or potters around in his bedroom for hours, as long as he stays up there!

Anyway, last night at eight, I brought them both up. I spent a few minutes with Jareth getting him ready for bed. When I went into Boann’s room, I found her on her bed already half-asleep!

It didn’t last, though. Throughout the night, Bronwyn and myself spent hours reminding her that she now sleeps in her own room. Between us, we got 6 hours sleep (11-5), with us taking turns to stay in there with her.

Hopefully things will turn out better today!

Overview: Learning PHP Data Objects, by Dennis Popel, is an introduction to PDO, which walks through the building of a believable test example - a library manager for your home library. Each chapter introduces a new facet of PDO and shows how to rewrite the appropriate parts of the application to slot the new ideas in. Very clear and easy to read. Non-PDO subjects are appropriately kept to the appendices.

I really couldn’t find very much about this book that I didn’t like. Ignoring the appendices, the book is 154 pages purely devoted to teaching PDO through examples, including error handling, working with BLOBs, even the creation of the M in MVC (Models).

I mentioned MVC there. One of my gripes with most tutorials of MVC is that they introduce the concept simply, then provide pages and pages of code with the end product which is “hello world”. Why I should go to all that trouble instead of simply writing <php echo 'hello world'; ?> to the screen usually escapes me. Dennis, however, concentrates solely on the Model and shows exactly why it’s a great idea. I think some more separation of concerns would have been better (don’t mix Author and Book SQL in the same object, for example), but the ideas were all good.

I think that if Dennis was going to show how the Model works, he should also have gone a little further and showed an example of an Active Record pattern as well. But I guess the point of showing MVC was more to show /an/ example of abstraction of the DB code, and that was sufficient.

The book covers a Library manager application all the way through from conception to implementation, demonstrating at all points that the code works with SQLite and MySQL (and by implication, all other DBMS’s) with a change of only the connection string.

Possible problems are explained clearly and solutions are provided. For example, Dennis explains why, after you compile the query select * from books, PDO (and indeed the database itself) does not know how many rows it will return. A solution, in the form of a very smart getRowCount() function shows a query-agnostic method for counting results of an arbitrary line of SQL.

Other areas that are covered in the book include error-handling, prepared statements and transaction-handling.

PDO can handle Prepared Statements even if the underlying DBMS cannot handle it, so it is possible to write your code in a cross-platform way. Examples of why you should use this are provided. One of the examples shows an efficient way to handle insertion or updating of a table using the same parameters for both cases, with the row-handling function deciding whether to use update or insert based on whether an ID was provided.

I feel the Transactions section could have been expanded a bit further. It is not explained how PDO handles this for DBMS’s that don’t internally support transactions, and I wouldn’t like to assume that they work all the time, only to find after deleting critical data that it’s not supported.

Overall, I enjoyed reading this book. Dennis is a good writer and I think he explained his thoughts very clearly.

On an aside, my four-year-old son Jareth loves Packt Publishing’s books. Sometimes when I go to read another chapter, I need to covertly steal the book I’m reading back from him. For a while, he made it a bed-time ritual to grab all the Packt books he could find around and bring them up with him to read in bed. I think he loved the screen-shots and the frequent code samples. He’s high-functioning autistic and likes literary constructs, and programming books are perfect for him in that regard. Thanks Packt, you’ve made my son (and therefore me) happy.

tribute image from Penny Arcade

Gary Gygax, who engineered a large part of my teenage years, is dead.

I started playing Dungeons & Dragons when I was perhaps 13 or 14, when my parents surprised me one christmas with a box-set of the Basic edition. Almost immediately, this became a hit, and a troupe of players was formed in school.

I’ve lost contact with the players over the years, but their names were Neil, Sean, Brian, Tiarnan, Anto and Gavin.

What D&D gave to me was an imagination and companionship. Once a week, I was able to escape from the drudgery of being an outcast and transform into someone else.

After a while, I transferred to AD&D (Advanced Dungeons And Dragons - an entirely new set of rules) 2nd edition. This was pivotal - the rules were more complex, but that didn’t matter, as the accompanying stories were so much more fascinating. I would buy (and in some cases, steal, to the amusement of the police - they expected young criminals in Tallaght to be stealing cars or mugging, not stealing books to feed a voracious imagination) manuals, read the rules, but study the accompanying short-stories and excerpts.

The goal of AD&D is not to beat up orcs, steal their treasures and amass a huge value in XP. As a dungeon master, I tried to reward the players for playing their roles passionately more than I’d reward them for the various atrocities they committed on the rapidly endangered bad-guy species in our make-believe world.

Through the game, I came across wonderful gems such as Margaret Weis and Tracy Hickman’s Dragonlance books - which would go on to be hugely popular. I always fancied myself to be a little like Raistlin/Fistandantilus - a weakling outcast who had big potential inside. Unfortunately, Raistlin was also a little, well, evil, but no-one’s perfect! His brother Caramon was a bit of a dweeb. Sorry if I mangle names a little - it’s been twenty years since I read the books!

The antics of Tasslehoff Burrfoot were sometimes annoying - the Jar-Jar Binks of the Dragonlance world. But it was fun to read the events of Fizban The Fabulous - an addle-brained sorcerer who would turn out to be very very important (and also turned up in another unrelated series by the same authors, as “Zifnab”).

Eventually we would go on to play other games such as Vampire: The Masquerade and the over-complicated but realistic Warhammer Fantasy Roleplay. We would always go back to A&D, though; nothing could beat it.

Gary, if there’s a heaven for gamers and dungeon masters, I hope you’re in it, enjoying a pipe with the great sage Elminster.