Quickshiftin - Clever Crazy Code

Passing ‘pointers’ to private methods in PHP

September 28th, 2015

If  you’re writing any code with Javascript, you’re surely familiar with the concept of a callback. Turns out callbacks have been available in PHP for a long time too, they just haven’t been first class citizens for as long. What’s really neat though, is with the advent of the Closure class in PHP 5.3 you can now pass callbacks to private methods!

More »

Viewing Inheritance through IoC Goggles

June 7th, 2011

Hugh?

So you’re trying to write loosely coupled code and you keep hearing this thing about inversion of control. Perhaps you read about it in the chapter on factories while reading your favorite design patterns book. Well to summarize, inversion of control is where a chunk of code acts as a container for another set of code, the container controls some overall algorithm or sets of algorithms and calls other code to implement certain portions of these algorithms. This is commonly referred to as the hollywood principle, “don’t call us, we’ll call you”. This could be as complex as an MVC framework or a simple implementation of template method somewhere in your codebase.

More »