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

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

Using a builder to construct complex classes

Wednesday, April 1st, 2009

Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters. Having something like that can make it more difficult to understand the code. In a case like this, you may ...

Avoiding endless switch-case structures with classes

Monday, February 2nd, 2009

Imagine the following: you have some form elements that need to render themselves. You have saved them in a database, as your users must be able to modify the forms. You have a bunch of different kinds of elements: a text field, a longer textarea field, maybe a field used ...

The problems faced by a common model interface in frameworks

Wednesday, December 17th, 2008

You sometimes see people asking why the Zend Framework (or some others) don't provide a library for the Model part in MVC. While ZF provides data access classes in the form of Zend_Db and related components, it doesn't provide any concrete examples of how you would implement a model class. ...

Food for thought: utilizing models in MVC

Saturday, December 6th, 2008

"What is a model" and "Is Zend_Db_Table a model" seem to be asked once in a while on #zftalk. Frameworks say they have a full model available, thus they are MVC frameworks ORM libraries say they generate models. It seems the ActiveRecord pattern has become somewhat synonymous with model. Pádraic Brady ...

Common widget design patterns

Wednesday, December 3rd, 2008

I've worked on quite many widget projects, and very often they have certain patterns that keep appearing. I'm calling these "widget design patterns" - let's take a look at a few.

Implementing swappable authentication methods

Thursday, August 21st, 2008

I've mentioned a CMS I'm working on in a couple of occaions. Lately, I've been tinkering with the user authentication part of it, and stumbled upon a small obstacle: How to make it easy to change authentication methods? Most of the time you probably would like to use a database to ...

What are the controller and model in MVC?

Monday, November 26th, 2007

A lot of people seem to be slightly confused about what the M and C, Model and Controller, of MVC are, in regards to web applications. What does the Model do? What does the Controller do? View is what everyone seems to know, though... I wonder why is that so? What is so ...