PHP in Action Rotating Header Image

Posts under ‘PHP’

Bad code is good for you?

Image by Balakov via Flickr

In The importance of bad code (or, WordPress and why I am a psychic), Marco Tabini proposes the idea that we need bad code. Or at least that we should be tolerant of bad code in open source projects because that invites participants that might otherwise not contribute.
This is an interesting [...]

Don’t refactor without unit tests

Image by niallkennedy via Flickr

Brandon Savage is writing a series on code improvement using a code example (starting with Peer Review: Taking Code And Making It Better). In other words, it’s about refactoring, which is practically my favorite subject. Although I don’t agree with all of it, it’s mostly good advice. I recommend it.
That said, [...]

Real programming with PHP 5.3 (part 4): A more realistic example

Image by hartboy via Flickr

My previous example in part 2 was just “hello world”, so I’m going to try for something more like the real world. You may find this example unusual, but it does work. I took the PageRange class I used in my July 2007 php|architect article and converted it to the JavaScript [...]

Sounds like an average PHP app to me

Image via Wikipedia

Dean Wampler blogs: Is the Supremacy of Object-Oriented Programming Over?
“The fact is, for a lot of these applications, it’s just data. The ceremony of object wrappers doesn’t carry its weight. Just put the data in a hash map (or a list if you don’t need the bits “labeled”) and then process the collection [...]

Most confused discussion in the known universe

Image by B Tal via Flickr

How confused can a discussion get? As confused as the discussion in the comments to Benjamin Eberlei’s Explicit Code requires no comments – Only bad code does. This discussion has a fake identity, and nobody seems to notice. As you can see, the blog post claims to be about code [...]

Show me your code comments and I’ll show why you don’t need them

Brandon Savage has written a blog post On Code Commenting And Technical Debt. He believes that code comments are a good way to minimize technical debt.

I’m surprised to find the term technical debt mentioned without being accompanied by the term refactoring. Refactoring is generally recognized (outside the PHP world) as the way to pay down [...]

10 ways to improve your code

Image by Jared Richardson via Flickr

I discovered a video presentation available from QCon SF 2008 by Neal Ford called 10 Ways to Improve Your Code. Although the examples are in Java, most of the presentation is relevant to PHP. There are some ideas here that I’ve never heard of myself, such as “anti-objects”.
Some of the [...]

Real programming with PHP 5.3 (part 3): Links

Image via Wikipedia

After the previous post in this series, additional independent implementations of the idea of JavaScript-style classes have turned up. So I’m going to list them and comment briefly on the differences. I hope this will be helpful to anyone who actually wants to use this in practice and needs to decide on the [...]

Real programming with PHP 5.3 (part 2): JavaScript-style classes

In part one of this series, we looked at the ability to use lambda functions or closures to process arrays. In this part, we will see how closures can be used to build classes in a completely new way.

After I did my own research, I discovered that someone had beat me to it. As early [...]

Ada versus Mars and Venus

Image via Wikipedia

On the carafe belonging to our coffee maker, there is a barely discernible spot that tells you how far to unscrew the lid in order to open it so that you can pour coffee from it without getting a flood of it in your lap. I never found this spot until it [...]