Categories


Loading feed
Loading feed
Loading feed

Junction -- a new persistance layer for PHP 5

Over the summer I started a project which I would like to introduce to you. Junction is a new persistance layer, much like Propel, written in PHP 5 and based on the popular Java persistance layer Hibernate.

Member Profile: Alex Schearer

I am a young programmer and am completing my undergraduate studies with a degree in philosophy and computer science. I love to program and talk about design. I am especially interested in web programming, and its relationship to common design practices.

Refactoring loops

Recently I was writing some code which manipulated a string based on the contents of an array. When I first wrote the code there were four methods which each iterated over a passed array. I saw this and thought it was a clear opportunity to refactor my code by moving the iteration into its own method. However as I was just about to do so I realized that the road was blocked; each method performed a slightly different operation inside the loop, so while it was clear that I had some redundancy in my system it was not clear how I could factor it out and preserve the unique contents inside the loops. Additionally I was uncertain whether it was worth the pursuing the common code which consisted of a single line. That was the end of the story, and the code never did get refactored. That said I was struck by a solution which I believe elegantly solves the problem outlined above and is well worth your time, and here it is.