Aug 16, 2007
My work has recently taken a departure from the usual web development as I’ve been “borrowed” by the other development team to help out with a Java project. Now, my Java is reasonable sound but yesterday I came across a curious situation involving passing about the current object.
In common with a lot of languages, the current object is represented by the ‘this’ keyword. I wanted to pass ‘this’ to a static method of another class. Of course, I can’t refer to the object as ‘this’ in the static method context as that would be ambiguous insofar as it could refer to the class with the static method I’m working with. This pattern is often used with callbacks where for example you might want to register a class with a particular listener objcet. To avoid confusion, I named the actual parameter in the static method
I assumed that I would reference the fields and methods of the object using
Code (java)
-
that.someMethod()
rather than
Code (java)
-
this.someMethod()
This is where the fun begins. Let’s call the original object
Code (java)
-
SomeObject theObject
and I want to call the static method
Code (java)
-
SomeClass.doStaticMethod(SomeObject that)
I would call that method, from within theObject, using
Code (java)
-
SomeClass.doStaticMethod(this)
When in theObject, I have access to private fields and methods since private fields and methods are within scope. I assumed the same would be true when I passed “theObject” as “this” to “SomeClass.doStaticMethod(SomeObject that)”. However, when I actually try to access private fields such as “that.privateField”, it would appear that I no longer have access. I could create appropriate accessor methods, but that would defeat the idea of encapsulation.
Does anyone have any ideas? Am I missing some fundamental (and so obvious I missed it) rule of scope or object passing?
Aug 15, 2007
I’ve finally found time to start investigating some other PHP frameworks, and after some brief research I decided to start off with Symfony. All is going well and so far I’m impressed with what Symfony can do compared with CakePHP… with a few exceptions.
I initially tried following the My First Project tutorial, but hit problems pretty quickly. It would seem that there was a problem with the PHP SQLite extension. The phpinfo() function verified that SQLite was indeed installed, but I couldn’t get any further on that trail. After reading a number of forum posts on the issue, it became apparent I should recompile Apache and PHP. I’m still not that confident with Linux to do that so I left it at that.
Then I followed the Askeet tutorial with more success as this tutorial uses MySQL rather than SQLite. However, I can’t get the URL rewriting to work as it should. I’ve checked my Apache configuration, the .htacces file and still no luck. If I load http://<project>/question I get a 404 error. If I load http://<project>/index.php/question or http://<project>/frontend_dev.php/question all is well. I’ll press on with this tutorial until I hit a road block, but this is really bugging me. Again, a few forum posts suggest recompiling Apache and PHP. However, the extensions that should be included in the new build are already present according to phpinfo().
I’m currently running Fedora 7 which installs Apache and PHP in its own odd way. Perhaps I should start from scratch by removing Apache and PHP with yum and compiling both from source. Although as I said I’m kind of reluctant to do that. If anyone has any ideas - let me know!
May 19, 2007
Up until recently my hosting was provided by Fasthosts. For reasons that have nothing to do with the experience I have had with Fasthosts I have had to move to an alternative hosting provider. After some research I opted to go with Hostgator’s Baby plan. The features included with this hosting plan are excellent for the small fee of £5.00 per month. And the technical support is brilliant. I initially had problems getting SSH access, but after raising the issue via the ticket system, I had SSH access within a few emails! [Read more]
May 7, 2007
It is with great sadness today that I say goodbye to our dog Honey. She lived a long and full life but ultimately her age and the poor health that accompanies a dog of her years got the better of her; this afternoon she was put to sleep.? I hope that she and Flint are together again in the doggy afterlife.

In Loving Memory of Honey and Flint.
Apr 13, 2007
Well it’s Friday 13th April today - and I’ve never been one for superstition - but…
I started feeling ill earlier this week and this morning it peaked. I phoned in sick to work. Partly because I’m not up to going around in circles with XSLT and XSL-FO trying to make an XML document pretty whilst coughing my lungs up and having my head filled with illness induced concrete; partly because I didn’t want to inflict this horrible cold on my colleagues. It was a shame because I had a meeting scheduled today that I wanted to attend - never mind.
As if that weren’t enough I eventually dragged myself out of bed to do some cleaning as my parents and sister are coming down tomorrow. Started in the kitchen, moved onto the living room and thought I’d put a load of washing on. BIG MISTAKE. It would appear there is a loose fitting in the plumbing under the sink. I can’t use the washing machine or sink unless I want a small lake in the middle of the kitchen floor. Have to wait until Monday for a plumber to come around and sort it.
Things to do this weekend:- buy new underwear and clothes or go to a laundrette; become skilled at washing dishes in a basin without putting water over the edge, thus flooding kitchen. Oh the joys!
Apr 2, 2007
Well another April 1st has gone by and I was fooled in a pretty big way! Roger Johansson posted that the W3 had announced WCAG2.0 was a Final Recommendation. Of course it didn’t occur to me for a moment what day it was. And worse still - I checked the W3c website - to find no news about it - even that didn’t start ringing alarm bells!
Oh well - shame on me… how did you get on with April 1st!?
Mar 15, 2007
Sitepoint have another competition on the go. The winner gets a copy of the new book “Principles of Beautiful Web Design”. The competition involves using CSS to style some simple markup that serves as an advert for the book. Unfortunately the markup hooks available for use with CSS are somewhat lean. I’ve given it a shot, as have others. Why don’t you have a go - you have until the 6th of April to enter as many entries as you like. Happy coding!
Mar 3, 2007
Aaargh. That’s all I can say about the number 38 service of Lothian Buses. Possibly the most inconsistent bus of all those that travel the roads of this planet (not that I ever use hyperbole - or litotes for that matter). Granted, it is one of the few buses that serve both the Western General Hospital and Edinburgh Royal Infirmary at each terminus respectively. However, if the bus requires extra time at either end to transfer the ill and infirm then please Lothian Buses, I implore you, lay on extra buses - double-deckers even (never a seat on this perpetually late bus), or alter the timetable accordingly. The bus was half-an-hour overdue in which time I watched three 33s, two 25s, four 3s (two of which arrived at the same time) pass me - none of which were of any use. Fate it would seem is not without a sense of irony; this “bus o’ doom” also serves the new flat I’m moving to at the end of the month. Thankfully there are a number of more reliable buses there! Here endeth the rant.
Mar 1, 2007
You may already have an OpenID from one of the many providers, for example username.myopenid.com. Wouldn’t it be nice if you could use your own domain name instead? Well you can! You may not actually host an identity provider capable of vouching for your ownership of your own domain, but you can always get username.myopenid.com to vouch for you.
This process is called delegation. You use your own domain name as your OpenID, but add some extra markup to the head element of your homepage that tells the relying party that you are delegating the responsibility of authentication to another server. The markup you need is:
Code (html4strict)
-
-
<link href="http://www.myopenid.com/server" rel="openid.server" />
-
<link href="http://username.myopenid.com/" rel="openid.delegate" />
-
<meta http-equiv="X-XRDS-Location" content="http://yoururl.myopenid.com/xrds" />
This will tell the relying party, that it should instead visit username.myopenid.com. You will then authenticate to this delegate server. Once successful, by implication of having authenticated to the delegate server, you have also proved that you own the domain from which you were directed.
The link tags are used for OpenID 1.x server discovery, and the meta tag for OpenID 2.x server discover. In order to be as compatible with OpenID consumers as possible, you should use both link and meta elements.