views:

360

answers:

3

Hi, does anyone have any thoughts on what would be considered good technicaly interviews for new php programmers. Im not meaning the little questions that are intended to know language specific intricacies but more on larger interview questions that potential employees may take an hour or 2 to solve in their own time and then come back with.

Specifically im looking at PHP and object orientated but are there any ideas on suitable problems that a php programmer should be able to solve within a couple of hours?

I am thinking that I want to have demonstrated object orientated techniques and also unit testing capabilities but as for that it can be anything.

+3  A: 

There are a lot of good problems available on Project Euler that may help demonstrate general problem solving ability and algorithm analysis. As for questions that demonstrate general knowledge of object oriented abilities you could develop an abstract class that provides an interface for something and ask a potential candidate to write an implementation for that class. This will help you critique their grasp of some OOP concepts and their familiarity with PHP at the same time.

thetaiko
A: 

You can ask them to implement an abstraction layer for interacting with databases. Specifically:

  • Consider an interface Query with following methods
    • bool execute() throws InvalidQueryException returns whether there were any results
    • string printAsXhtmlTable() throws InvalidStateException
    • array getAllRows([$associative = FALSE]) throws InvalidStateException
    • array getRows(int $i[, $associative = FALSE]) throws InvalidStateException
    • array getColumnNames() throws InvalidStateException
  • Build a Countable, Traversable and with array-like access abstract class that also implements Query (give some UML diagrams for the SPL interfaces). This abstract class must implement at least the printAsXhtmlTable() method.
  • Extend this abstract class for MySQL and PostgreSQL using these functions (and give a list of functions for the mysql and postgresql extensions). These should all have this constructor:
    • __construct(string $query [, mixed $param1 [, mixed $param2 ...) throws InvalidArgumentsException (if the number of arguments is different from the number of placeholder in the query

EDIT: Although in PHP constructors can be specified by an interface (and this can something be useful), it's kind of against good OOP pratice, so I moved its specification to the concrete classes.

This tests their knowledge of

  • XHTML
  • Escaping XHTML
  • OOP
  • Databases, including preventing SQL injection
Artefacto
Do you think is acheivable within a couple of hours for an average php programmer? What about recent graduates / junior positions - do you think this would be beyond their ability?
David
I do. The methods they have to implement are all thin wrappers around existing PHP functions, with the exception of `printAsXhtmlTable`. 2 hours should be plenty of time.
Artefacto
Recent graduates also?
David
The only difficulty I can see is that they might not know the SPL interfaces, but that's a matter of giving a UML diagram and a short description of the methods. If you want to hint them in a simple direction for implementing `Traversable`, give them the `IteratorAggregate` and `ArrayIterator` interfaces instead of the `Iterator` interface.
Artefacto
+2  A: 

Zend ("the PHP company") offers a PHP certification programme. You could require your applicants to complete that certification either before or within a certain period after they are hired. Or you could simply draw some inspiration on which topics your interview should cover from their website.

mqchen