Archive for the ‘Programming’ Category

Unit testing 5: test-driven development

Saturday, July 4th, 2009

In this post I'll introduce the methodology known as test-driven development, and how to use it in your projects. The difference between "normal" and test-driven development (TDD) is that when doing TDD, you write unit tests for your new code before writing the code itself. This way you ensure good test ...

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.

How WidgetCity does a tile-based map using just CSS

Monday, June 15th, 2009

My city building game, WidgetCity, displays the city as a table, each cell of a table representing one tile. The tile map is done purely using just CSS, and CSS classes. The map is also scrollable. How is this all done?

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 ...

Unit testing: Introduction

Friday, June 5th, 2009

Due to popular demand, I'll be writing a bunch of posts on unit testing. In this post I'll introduce unit testing: What it is, when it's a good idea and when it might not be. I'll also discuss a bit about what makes for a good unit test. Next week I'll post ...

How to pass variable values to JavaScript

Friday, May 22nd, 2009

A relatively common task in today's Web 2.0 apps is passing values from a server-side script (or through a link) to JavaScript, affecting the client-side script execution. Not surprisingly, there are a few ways to do that. Let's look at three and their pros and cons: Embedding scripts into templates Passing variables ...

Dealing with different password validation schemes in a single app

Wednesday, May 20th, 2009

If your application is well thought out, you would not want to save any data that isn't valid. So what do you do, when you need different validation schemes, say for passwords, depending on some special case? For example: Your user passwords need to be at least 8 characters long and ...

Doctrine vs. Propel: 2009 update

Saturday, May 16th, 2009

The best PHP ORM libraries, Doctrine and Propel. Last year I compared them to each other, and now it's time to get a fresh look at how they have advanced in about a year - Is Doctrine still the better of the two? This time, I'll also look at the features ...