about me about me
photography photography
software projects software projects
contact me contact me
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.


comments

No comments for this post.