about me about me
photography photography
software projects software projects
contact me contact me

As of Javascript 1.6 indexOf() is a method available for use with Arrays. However, there’s one subtle difference when operating on a String and an Array, both are case sensitive, Array.indexOf() is type sensitive. This is documented but for those of you who’ve not bothered with the documentation, and it’s not working as expected, here’s a heads up on a subtle gotcha …
Read the rest of this entry »

25
Nov

I’m surprised I’ve not run into this before but Javascript has two sub string methods.

[String].substr(start, length);
[String].substring(indexA, indexB);

To clarify by example:

var name = "Greg's Blog";
alert(name.substr(7, 4)); // Blog
alert(name.substring(7, 11)); // Blog

Minor but caught me out this afternoon.

27
Feb

I can’t believe I never stumbled across this before; I’ve seen a few posts about Groovy on dzone.com previously and just ignored them. A couple of weeks ago however I bother to investigate this language – how I wish I’d done this earlier!
Read the rest of this entry »

It’s hard to drag a community the size of PHP’s towards such things as standards and using frameworks. From my experience many PHP developers still struggle/refuse to adopt others standards.

When I started PHP, PEAR didn’t exist, and even when it did (and probably even today) much of community is used to “rolling their own” solutions for 99% of tasks. Most developers I’ve worked with don’t trust/use PEAR classes and I can’t really blame them. Most early efforts were authored by developers who at the time didn’t really grasp the OO concept and made god classes. Read the rest of this entry »

25
Nov

Java impressions

posted 2006 // code, java // 0

This was meant to be a lengthy comparison of the stumbling blocks I found learning Java having come from PHP. However learning Java is currently on the back burner so I thought I’d post what I have anyway. Read the rest of this entry »

04
Oct

I just found a blog post by Mark Dominus about design patterns being a weakness in a programming languages. I’d not given patterns enough thought to recognise this fact but when reading this it’s obvious.

It’s interesting to learn a little history about where some C based (inc PHP) syntax comes from, namely the $object->method() notation originating from C structs. As well as an example of (what was probably one of the first) design patterns from the 1950′s:

Recurring problem: Two or more parts of a machine language program need to perform the same complex operation. Duplicating the code to perform the operation wherever it is needed creates maintenance problems when one copy is updated and another is not.

Solution: Put the code for the operation at the end of the program. Reserve some extra memory (a “frame”) for its exclusive use. When other code (the “caller”) wants to perform the operation, it should store the current values of the machine registers, including the program counter, into the frame, and transfer control to the operation. The last thing the operation does is to restore the register values from the values saved in the frame and jump back to the instruction just after the saved PC value.

This is describing what we take for granted in every programming language today – functions.