Jun 30 2009

Singletons in PHP

John

We’re going to keep this one short and oh-so-sweet. First of all, let’s take a brief moment of silence for the late, great Michael Jackson. *Sigh*

Now, on to Singletons. One of the most common assumptions I hear about the Singleton pattern is a blatant declaration to simply not use them – as if they could absolutely never possibly be useful for anything, ever. That is, of course, very lame.

Continue reading


May 27 2009

$$: Cache, or Crash

John

I recently revised my opinion of a little JavaScript framework you may have heard of. Frankly, I just got tired of simulating inheritance on my own, and Prototype does a better-than-decent job of class extensions, which is more than I can say for other libraries like JQuery or MochiKit.

However, that being said, it’s also worth noting the fact that Sam Stephenson – creator of the Prototype framework – is also a lead developer on RoR, which means that no matter what framework he’s building or what language it’s in, he’s going to make sure arbitrary – borderline useless – methods and helper functions plague the code base. Among these are things like Enumerable.zip, Element.makeClipping, and the oh-so-overrated Rails “dollar-w” Array method, $w. Now, one could argue that absolutely every inch of Prototype – or any framework, for that matter – simply consists of convenience methods and shorthand coding patterns – and that may be true. I mean, let’s face it, a framework can only utiliize a languages already-built-in capabilities – it can’t add to them. Regardless, I have become rather fond of using Prototype’s XPath parsing engine.

You may recognize some Prototype functions that utilize the XPath DOM traversal method like $$Element.getElementsByClassName and
Element.getElementsBySelector. However, these are H-E-A-V-Y on your browser. How heavy? YMMV, but generally, pretty fucking heavy. So heavy, in fact, that Google decided this was a good idea.  The question is, do I care? Meh, nah, not so much. I increase browser performance like Chris Brown punches out pop starlets.

Continue reading


May 14 2009

Frameworks: Tendency Towards Dependency

John

We’ll get to that in a minute.

Welcome to the blog! If you’re here, and you need an explanation, you’re probably lost. However, because I’m a good sport, you’ve reached the life and times blog of John Napier, a 20-some-odd year old variety-of-things guy. If you know the difference between NP-Hard and NP-Complete, or you feel slightly offended that I’d even ask, you belong here. If you think it’s possible I insulted your mother at some point in that last 60 or so words, you might find your time better spent perusing around some other, less-technical articles – in which case, you’re currently out of luck, as this is my first post. Let’s be on with it then.

Continue reading