Skip to content


The “Service Locator” software design pattern is an Object UNoriented fad

The Object Oriented Programming (OOP) methodology has origins dating back to the 1950s, but revolutionized the software industry when it became the dominant programming methodology in the 1990s.  It has continued to dominate to this day where it remains the foundation of all of modern major software development languages including C++, Java, Ruby, PHP5, and many more.  OOP is universally accepted as the best-practice methodology for software development across the majority of computing platforms and provides developers with a unique approach to software design that elegantly mimics real world concepts through the use of objects.

Service Locator is a serivces oriented design pattern which misappropriates concepts of the Services Oriented Architecture (SOA) paradigm.  SOA arose from a need to integrate discreet systems that were built independently using incompatible technologies (eg: EJB and CORBA) across networks.  It revolutionized software integration and has facilitated countless integrations of otherwise completely incompatible systems and platforms.  SOA concepts work extremely well when applied to the software integration space, however a services oriented architecture has no place in application development.  The Service Locator pattern capitalises on the success of SOA by tapping into the hype around services oriented architecture, but the problem is it applies the concepts in the wrong context, in the same way a screwdriver is an excellent tool for fastening a screw, but not for a nail.  A software application by definition is a tailored package of software components specifically designed to work together in providing a set of functionality.  There are no incompatible technologies as the software developer carefully chooses the components that are used.  A services oriented design approach, and therefore a Service Locator pattern is not required, not useful, and is generally counter-productive.

By its very name, everything in OOP is oriented around the concept of an”Object”. The Service Locator pattern breaks this pattern by orienting everything around the concept of a “Service”. “Model” objects within the Service Locator pattern (ie: objects representing domain entities) are generally reduced to dumb containers for data offering little advantage over primitive structures such as arrays. Service Locator pundits stress to never allow domain objects the ability to know about the service manager, causing these objects to become detached, powerless, and oblivious of the wider system in which they reside. Even the relationship between domain objects and the software developer becomes fragmented as the Service Locator pattern relies on Services to do just about everything.

This is in direct conflict with the most fundamental of OOP principles which require that objects interact with each other and specifically are able to “do” useful things (ie: perform actions) via methods above and beyond simply getting and setting their own attributes.  A classic example is the “Car” object which has the methods “Drive” and “Stop”.  A car is a complex machine with many many internal parts (pistons, spark plugs, camshaft, etc), however car drivers are not generally concerned with all of this as the car does a great job of abstracting away all of its complex internal components into a simple method “Drive” which is invoked by the driver depressing one pedal (or invoking one method).  The Service Locator pattern breaks this so that a car no longer knows how to drive.  In fact, even the spark plugs no longer know about the pistons.  Instead, objects become little more than a catalogue of parts which rely on a service to instantiate and assemble them in the same way a puppeteer pulls the strings on a puppet.  In OOP, objects were never intended to be merely puppets.

The Service Locator pattern wraps and proxies the highly structured and namespaced class hierarchy system offered by OO languages with what’s essentially and unstructured, global key/value pair system that offers no advantage except to satisfy someones perverted desire to implement the Service Locator pattern.  Global variables are generally avoided in software development due to several problems they introduce into a system, especially around security and scope.  Services stored in the global registry are generally done so in a loosely-typed fashion which is not only at odds with OOP principles but compromises the strongly typed qualities of languages like C# and Java.

The Service Locator pattern violates the Interface Segregation Principle of the SOLID set of Object Oriented Design principles which states that “clients should not be forced to depend on methods they do not use”.  It’s impossible for the Service Locator design pattern to satisfy this as the Service Manager can expose any number of method signatures globally to the entire application, and these can be changed at any time without detection at compile-time, thereby resulting in run-time errors.

The Service Locator software design pattern is an object UNoriented fad that will disappear into obsolescence as more and more people speak out against it and its related concepts.  Personally, I think that can’t come soon enough.

Posted in Uncategorized.

Solved: “Instance reachability check failed” when launching an AWS EC2 instance from a custom AMI


  1. You have created your own Linux AMI from a snapshot, and
  2. You launch an EC2 instance from your AMI, and
  3. The Instance reachability status check fails when you try to start up the machine


Sample screenshot

Under these circumstances, you are unable to access the instance at all.


How to troubleshoot

  1. In the EC2 “Instances” screen, select the instance
  2. From the “Actions” menu choose “Get System Log”
  3. Scroll to the bottom and look for error messages


A solution to a common error

Under the above scenario, a common error you may receive is:

couldn't mount because of unsupported optional features (240)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)

This is caused due to not specifying the Kernel and/or RAM ID when creating the AMI from your snapshot. To solve:

  1. In the EC2 “Instances” screen, select the instance that you wish to create an AMI from
  2. In the “Description” tab, find the Kernel ID and RAM disk ID
  3. Create a new AMI from your snapshot
  4. In the AMI creation wizard, be sure to select the Kernel ID and RAM disk ID that you got above
  5. Finish the process

The instance should start now that the AMI is properly configured.


Posted in Uncategorized.

“Access denied for user” error message when logging into phpMyAdmin on GoDaddy hosting

If you are setting up a MySQL database in your Godaddy hosting account, note that there is a problem with their MySQL password validator.  In short, make sure you don’t include a hyphen (dash) in your password.

Even though it doesn’t mention anything about it being a problem, and even though it will accept a password with a hyphen, you wont be able to log into the database using phpMyAdmin.

I reported this to Godaddy technical support, however they simply stated they were “happy to hear” that I worked out the problem and solved it myself and thanked me for my feedback.

Bad luck to everyone else who runs into this problem I guess.  Unless you somehow manage to find this blog post.

Posted in Uncategorized.

Godaddy Hosting – pageok message


If you you are using Godaddy shared hosting for your website or blog, you may be surprised to encounter a blank page when you attempt to navigate to your website.

If you are using GoDaddy shared Linux hosting, you may see nothing but the word “pageok”.  If you view the source of the page, you may see:

<!-- pageok -->
<!-- managed by puppet - hostingcms02 -->

If you are using GoDaddy shared Windows hosting, when you view the source of the page you may see some html and JavaScript, as well as something along the lines of:

<!-- pageok -->
<!-- 04 -->
<!-- 368 -->
<!-- 7.12-->
<!-- Copyright -->

You might try and search Google for answers on how to solve this, and even Godaddy’s support site where you will find confusion and  statements from support staff  like “it is difficult to troubleshoot the issue” and “you’ll need to get in touch with our support team“.


In reality, its not “difficult to troubleshoot the issue” at all, and you’ll be glad to know that you don’t need to get in touch with their support team.  The pageok message will occur when you have a host record (ie: “A” record) in the DNS zone file for your domain that is pointing to a GoDaddy shared hosting server, however the domain name is not set up in your hosting account.


1. Make sure you have the domain name set up in your hosting account

To do this:

  1. Log in to the Hosting Control Panel.
  2. Click the icon that says “Hosted Domains”
  3. Make sure your domain is shown.  If not, add it.

2. Make sure the entry you created in the “Hosted Domains” section of your Hosting Control Panel is not still pending setup.

When you add a domain to your hosting account, it can take a LONG time.  Up to 24 hours, in fact. To check if yours is pending:

  1. Log in to the Hosting Control Panel
  2. Click the icon that says “Hosted Domains”
  3. Find your entry and check its status.  If its status is “pending” then you are going to see a pageok message.

 Example of a configured domain that is still pending setup.


If the status says “Setup” and you STILL see the pageok message, then continue to steps 3 & 4:

3. Make sure the correct IP address is assigned to the host record in your domain’s DNS Zone File.

If you also have your domain registered with GoDaddy, when you add the domain to the “Hosted Domains” list in the Hosting Control Panel, GoDaddy will also take the liberty of modifying your DNS zone file for you automatically.  To check this occured correctly:

  1. Log in to the Hosting Control Center
  2. Take a look on the right hand side of the screen.  There is a box titled “Server Details”.  Under that there is an IP address displayed.  Note this IP address down somewhere.

4. Make sure your host record (“A” record) is pointing to the correct IP address.

If you have your domain registered with GoDaddy, the steps are below (it will be similar for other domain registrars)

  1. Log in to the “Domains” tool.
  2. Select your domain
  3. Click “DNS Zone File”
  4. Check the relevant host record (you may have several).  If there is only one it will have the host name “@”.  Make sure the IP address matches the one you noted down before.  If not, change it.

Note: DNS changes can take a long time to propagate through the Internet.  If you make a change to your DNS Zone File, it could take up to 48 hours to full propagate.  Further, some devices such as home routers cache DNS records so you may need to wait some time before testing changes to DNS records.

Posted in Uncategorized.

Installing PEAR, cURL, Selenium, and PHPUnit on Windows

These are some rough instructions having gone through the process.  I’ll update and refine these if I ever do it again.  Feel free to leave some comments with additions/corrections.  Make sure you have PHP installed first.

Install Pear


  1. Download PEAR
  2. Extract the archive using WinRAR
  3. Create a “PEAR” directory in  C:\PHP
  4. Copy the contents of the PEAR-x.x.x directory to the PEAR directory you just created
  5. Download Console Getopt, Archive Tar, and Structures Graph
  6. Create the directory c:\PHP\PEAR\Console.  Unzip and copy “Getopt.php” from the Console Getopt zip file into it.
  7. Create the directory c:\PHP\PEAR\Archive. Unzip and copy “Tar.php” from the ArchiveTar zip file into it.
  8. Create the directory c:\PHP\PEAR\Structures. Unzip and copy “Graph.php” and the contents of the “Graph” directory from the Structures Graph zip file into it.
  9. Edit your php.ini and add your php PEAR directory to your include_path
  10. Edit your system environment variables as follows:
    • PHP_PEAR_BIN_DIR = C:\PHP\PEAR\scripts\
    • PHP_PEAR_PHP_BIN = C:\PHP\php.exe
  11. Add C:\PHP\PEAR\scripts to your “Path” environment variable
  12. Run a command prompt as Administrator
  13. cd to C:\PHP\PEAR\scripts
  14. Create a pear.ini file in c:\Windows.  Alter the permissions so that any user can write to and modify it.
  15. Run the following commands:
    • pear config-set auto_discover 1
    • pear config-set bin_dir c:\PHP\PEAR\scripts

Enable cURL

  1. Copy php_curl.dll from the php “ext” directory to the Windows System32 directory
  2. Edit php.ini and uncomment the line that references the cURL extension.

Install PHPUnit

  1. You need to install specific versions of PHPUnit components if you are running Zend Framework 1.x (see:  From the administrative command prompt you opened earlier, run the commands:
    • pear channel-discover
    • pear install --alldeps --force phpunit/PHPUnit
    • pear install phpunit/DbUnit
    • pear install phpunit/PHPUnit_Selenium
    • pear install phpunit/PHPUnit_Story
Install Java JRE
  1. Download JRE
  2. Install it as normal
Install Selenium
  1. Download Selenium Server
  2. Create a directory called “Selenium” in C:\Program Files\Java\jre7\bin
  3. Copy the file you downloaded in step 1 into this directory.  It should be called “selenium-server-standalone-x.xx.x.jar”
  4. Create a new MS batch file called Selenium.bat on your desktop.  Inside, type the command
    • java -jar "c:\Program Files\Java\jre7\bin\Selenium\selenium-server-standalone-2.25.0.jar” (note: Include the quotation marks and substitute the version number for the version you downloaded)

Download a PHP webdriver library

  1. I like the Facebook one:

Run Selenium

  1. Execute the bat file you created for Selenium above.  This will lauch the selenium service that will listen for incoming commands from your test scripts.

You’re now ready to write PHPUnit tests using the PHP webdriver library. This library will talk to Selenium via the port that it opens (4444) when you run the batch file.


Posted in Uncategorized.

Recovering data from a broken, clicking hard drive

I’ve been burned in the past with data loss, so now I keep backups of all my important stuff. However, I did keep one old IDE external hard drive for archiving old stuff that wasn’t backed up. I figured these are old files that I don’t need anymore so I could handle a situation where they were lost.

Well, of course that hard drive stopped working. Actually, I carry both that drive and my backup drive in the same wallet and BOTH of them stopped working at the same time with the same symptoms (clicking, not recognised by the OS). I can’t understand how this happened as I never dropped them or anything like that. Having the two break at the same time was bizarre and scary (and costly).

So even though I was prepared to lose the archived files, I thought I’m going to try and recover them. I saw a few articles about freezing the drive for several hours in order to get it working again. What I decided to do was slightly different, and IT WORKED.

DISCLAIMER: This advice is provided for information only and is not recommended unless you are willing to potentially lose all of your data permanently. There is nothing elegant about this solution – it’s a brut force hack and you would only consider it as a last resort. Subjecting hard drives to extreme temperatures and condensation will damage the platters forever and this method will most likely ultimately render the hard drive unusable.

Step 1: Remove the hard drive from the casing

You are best to work with the drive directly. This will allow the cooling process to work.

Step 2: Put the drive in a zip lock bag

Make sure its a good quality one. Any condensation from the ice will enter the drive and destory it before you even get to do anything.

Step 3: Put two ice packs into plastic bags

This will help keep moisture contained.

Step 4: Sandwich the hard drive between the two ice packs

Be careful not to apply pressure to the top or bottom of the drive casing – this can destroy a hard drive instantly.

Step 5: Connect and disconnect the drive until it decides to work

Plug the drive in. If it clicks, unplug it and try again after a minute or so. Mine was on ice for about 4 minutes before it decided to spin up.

Step 6: Quickly transfer the files to another hard drive in the order: Most important to Least important

I quickly transferred the files across to another drive. Make sure you work quickly as the drive could die permanently at any time. Throw this drive in the bin afterwards – its gone.

Posted in Uncategorized.

Using the MySQL IN expression where there are NULL values

If you try to use the MySQL IN or NOT IN expressions in your query where the list of values includes NULL, you will find MySQL ignores the null records.  For example:

Table_A      Table_B
=======      =======
ID           ID
--           --
1            1
2            2
NULL         NULL

   FROM Table_A 


You can see that the null value is missing. This is normal behaviour and complies with SQL standards, but what if you needed null values to appear? You can add an OR condition that includes nulls only if they appear in the destination table. A little inefficient, but it works. It can be achieved like this:

    FROM Table_a



Posted in Uncategorized.

Xerox WorkCentre 228 and Windows 7 64 bit

These instructions detial how to set up a Windows 7 64 bit computer to use a Xerox Workcentre 228 printer connected to the LAN.


The printer needs some settings set first.  Log into the printers UI using a web browser and set these settings:

  1. NETBIOS name 1 – Must be blank
  2. Printer class – PCL/PC Kit


  1. Download and install the Xerox Global Print Driver for Windows 7 x64
  2. Follow the isntructions to install the printer (eg: enter the IP address, give it a name, choose the Xerox driver, etc)
  3. Once installed, under “Devices and Printers” right click the printer and select “Printing Preferences”
  4. Under “Paper/Output” tab, change “Ouput Color” to “Black and White”
  5. Under “Advanced” tab -> “Document Options” -> “Image Options”, change the “Graphics Mode” to “Raster”
  6. Apply that change
  7. Right click the printer again in “Devices and Printers” and select “Printer Properties”
  8. Go to the “Advanced” tab
  9. Uncheck “Enable advanced printing features”
  10. Click the “Print Processor” button

Posted in Uncategorized.

Migrating from Visual Source Safe (VSS) to Subversion (SVN) using VSS2SVN – Step by step

These are my notes for using the VSS2SVN tool to migrate a project from Visual Source Safe to Subversion. These notes were tested using Windows 7 32bit edition.

  1. Download and install VisualSVN Server version 1.6. It’s very important to install version 1.6 for the purposes of the migration. This version is very old but is required for the VSS2SVN application. VisualSVN luckily make all previous versions available so this is very handy.
  2. Download and install VSS2SVN.
  3. Make a copy of your SourceSafe database. This is the directory where VSS has been storing all your revision data. In this directory will be a file called “srcsafe.ini”. Don’t work with the original unless you like taking risks.
  4. Open the VisualSVN Server interface.
  5. Select “Create new user”
  6. Create a user account for yourself
  7. Right click on “Repositories” and chose “Create New Repository…”
  8. Enter a name corresponding to the name of the project you are migrating. Select “Create default structure”.
  9. I don’t get it and I don’t know why, but you must set a pre-revision property change hook. Right click your repo and choose “Properties”. Go to the “Hooks” tab, click “Pre-revision property change hook” and click “Edit”. In the textbox enter: exit /b 0
  10. Now we need to analyse your VSS repo becuase most of the time there are corruptions and VSS2SVN wont work if thats the case. From the command line enter:
    • "C:\Program Files\Microsoft Visual SourceSafe\analyze.exe" -F -V3 -D "c:\path\to\your\copy\of\the\sourcesafe\database\'data'\directory"
  11. If that step fails, your VSS database might be too corrupt to migrate (or even use)
  12. Check out a working copy of the Subversion repository you just created. From the command line enter:
    • "C:\Program Files\VisualSVN Server\bin\svn" co http://<HOSTNAME>/svn/<REPO NAME>/trunk/ c:\path\to\working\copy
  13. Now open VSS2SVN. Enter the following settings:
    1. Path to Scrsafe.ini: Enter the path to srcsafe.ini in your copy of the VSS database you made
    2. Username: The username you created in VisualSVN
    3. Password: The password you chose when creating the user in VisualSVN
    4. VSS project to use: Enter a dollar symbol ($) followed by a backslash (\) followed by the name of your VSS project as can be found using the Visual SourceSafe Explorer that comes with VSS. Eg: $\MyProject
  14. Click “Find files in source safe”. If you get an error saying a weird file like nbaaaaaa.b was not found, your VSS repo is probably corrupt and you need to run the analyse tool as mentioned above.
  15. For “Working Directory” enter the path to your Subversion working directory you created when checking out above.
  16. For “SVN path to use” enter URL of the trunk of your Subversion repositiory you created. Eg: http://<HOST NAME>/svn/repos/<REPO NAME>/trunk/
  17. Click “Migrate to subversion”
  18. Sit back; it might take a while

After you’ve migrated all your projects, it would advisable to upgrade your VisualSVN and Subversion.

Posted in Uncategorized.

Ultimate PHP error reporting wizard

Instructing PHP which errors it should report on is not straightforward. You have to understand binary and bitwise operators. I decided to make a tool that takes the hard work out of it so you can get on with your job creating your web app. Enjoy.

Posted in Uncategorized.