View Single Post
Old 10-24-2007, 10:00 AM   #2 (permalink)
Karl
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Hi Andrew,

The class looks fine to me. Setting default values in the constructor is a good thing, it provides a consistent place for property initialisation. With that said, if not all properties need to be set via the construct call then I would suggest adding a few "settor" methods, for example, to set the title independently of the constructor then you could add this method:

PHP Code:
public function setTitle($szTitle)
{
    
$this->m_szTitle $szTitle;

If you need to access any of these properties outside the class you should also create "gettor" methods to do this, such as:

PHP Code:
public function getTitle()
{
    return 
$this->m_szTitle;

Both the gettor and settor methods are only any use when you make your class properties hidden from outside the scope of the class (private or protected), they allow users to change the values of your properties but only by using the rules that you specify in you settor. I would suggest this change as an improvment.

As for your santize method, this isn't the cleanest approach to validation but it looks OK for its the task it is supposed to do.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote