The “do X or die()” pattern must die

Wednesday, July 28th, 2010

What's the most common pattern for error handling you see in beginner's PHP code? - That's right, do_X() or die('do_X failed);. That's nice and all, as at least you have some sort of error handling, but I think this way of handling errors must go. There is no place for ...

Wicket from the point of view of a PHP developer

Wednesday, July 14th, 2010

Not long ago, I had to learn some Wicket. What is that? In this case it has nothing to do with cricket - The Wicket I'm talking about is a Java web application framework. I've mostly used PHP and Python to do server-side web application sort of programming. Compared to what ...

Refactoring explained to an absolute beginner

Saturday, June 26th, 2010

Recently while on a drive with a non-programmer friend, I talked with him about code complexity and manageability, how very complicated code is detrimental to productivity and stuff like that. Later on, I decided to explain it to him with actual code examples, although the most he has ever done ...

Benefits of Developing With Microsoft AND Open Source

Friday, February 26th, 2010

The Internet seems to be the latest battleground for the computer age-old struggle between Microsoft and open source solutions. For some reason, many web developers like to engage in holy wars over various web site hosting solutions and development platforms, fiercely defending their beloved vendor's suite of products. They battle ...

Did you think your site validated input properly? Think again!

Wednesday, October 21st, 2009

You’ve written a PHP based web app, and you’ve made sure it doesn’t cause errors if the user submits unexpected values via any URLs or forms. But there’s something you quite likely forgot to test: What if the data that’s expected to be a singular value happens to be ...

What is a null object, and when are they useful?

Saturday, September 12th, 2009

If you've written code, you've probably used the value null to indicate some variable is not set. This is perfectly good, but did you know there's more to nulls than just the value null? There is also a null object, which doesn't really have anything to do with the value null, ...

Unit testing 4: Mock objects and testing code which uses the database

Friday, June 26th, 2009

After learning to write tests and some good testing practices, it's now time to look at mock objects. When testing a class which needs an instance of another class to work, you do not want to depend on the other class too much. This is where mock objects come in - ...

Unit testing 3: Writing tests for existing code

Wednesday, June 17th, 2009

Now that you know what unit testing is and how to write and run tests, it's time to look at writing tests in more depth. Today we'll take an example class and write tests for it. We'll also introduce some common testing methodologies.

Unit testing part 2: Writing and running tests

Wednesday, June 10th, 2009

Continuing from the unit test introduction, we will now continue and take a look at how to write tests and ways to run the tests.

Refactoring

Monday, June 8th, 2009

Today I'd like to point out a bunch of good articles about refactoring - the process of improving code without changing the functionality. Sameer Borate has written four posts about the topic in his blog, and I encourage you to check them out: Refactoring: An introduction to PHP programmers Refactoring 1: Conslidate ...