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 [...]
Posts Tagged ‘PHP’
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 [...]
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 [...]
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 [...]
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 [...]
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 [...]
Real programming with PHP 5.3 (part 1): array processing
You may have heard of the new features that are scheduled for PHP 5.3, but who knows what they can be used for in real programming? I took the time for some experimental research, and came up with a few examples. At the PHP UK conference, I saw Sebastian Bergmann’s presentation on lambda functions, closures [...]
One behavior != one assertion
Image by libbyrosof via Flickr The debate on the “one assertion” principle continues. Pádraic Brady and I agree on the general principle, but since he is so categorical in his second article, I needed to inspect his reasoning more closely. It’s clear that our disagreement is more than superficial. The more I think about it, [...]
One assertion per test—always?
Image via Wikipedia Pádraic Brady pleads for the principle that a unit test method should have only one assertion. His point is perfectly valid; there are several good reasons why one assertion per method is a smart guideline when writing unit tests. But since he drags up the term “lazy”, I feel the need for [...]
Type hints are not hints
Image by Franco Folini via Flickr As Kevlin Henney pointed out at the PHP UK Conference 2007, PHP type hints are not hints. Rather, they are instructions to PHP to check the type. That may not be terribly important, but it’s worth pointing out, since confusing terminology is less confusing if you understand how it’s [...]