Category Archives: Programming
PHP Pitfalls Part 2 – Code Blocks
In PHP blocks may stand on their own line. For this reason if you take the following code: public function foo() { $array = array( 1, 2, 3 ); $copy = array(); for( ; $value = current( $array ); next( … Continue reading
How the Data Mapper pattern enhances code refactoring
We all know code needs to be refactored. Duplication sometimes need to be factored out. Sometimes we think of a more clear name for a method or variable and wish to rename something. Sometimes we accidentally use names that are … Continue reading
Tony Marston. Programmer fish or Troll?
Tony Marston is a troll.
He doesn’t understand the difference between a pattern and a methodology. If anyone writes him and says they find patterns useful, he will immediately assume you use patterns as a methodology (like him).
I mean why else would you write an article called “design patterns are dead”.
Ps > this post has been made in satire of his “crazy headlines” writing style. Maybe he should write a pattern on language on this next. Continue reading
PHP Pitfalls, common causes of bugs
Crazy E_NOTICE behavior . Turns out $foo = null; count( $foo['bar'] ); is Valid! .. Where as.. $foo = array(); count( $foo['bar'] ); Will blow up your application in your face (will trigger E_NOTICE errors ). Which we actually want … Continue reading
Conflicting Model Overrides in Magento Extension Architecture
I have been using Magento for about one year. I have written one successful commercial extension ( for automotive ecommerce ) Lately, one of my clients informed me of incompatibilities between the SQLiReverse cross selling module extension and my extension. … Continue reading
Firefox dynamic javascript fields not posting
Thanks to Tom for this, who complains “other developers never seemed to mention the problem in their blogs”, so here ya’ go. I ran into an issue I sank a little time into. My Jquery generated forms weren’t working in … Continue reading
Case insensitive URLs / module names with Zend Framework routing
class Ne8_Controller_Request extends Zend_Controller_Request_Http { /** * Retrieve the module name * * @return string */ public function getModuleName() { if (null === $this->_module) { $this->_module = $this->getParam($this->getModuleKey()); } return ucfirst( strtolower( $this->_module ) ); } } Then in your … Continue reading
Setting dynamic arguments / paramaters in constructor ( ala call_user_func_array for objects ) via reflection
So PHP has a reflective API which is neat, you can do: $command = ‘setValue’; $myObj->$command(); but what happens if you need to also set a variable number of variables with your method. For this PHP introducescall_user_func_array. For the first … Continue reading
Setting up helper paths in Zend Framework bootstraps
The Zend documentation is a bit sparse around this topic, it mentions setting up helper paths in the bootstrap, but does not go into detail. The Zend API documentation provides no clear cut answer either. For those of you who … Continue reading
SPL Object iteration in PHP5
The easy way. class myClass implements IteratorAggregate { $this->array = array( ‘one’, ‘two’, ‘three’ ); public function getIterator() { return $this->array; } } $myClass = new myClass(); foreach( $myClass as $property ) { echo $property; }