
Originally Posted by
wysiwyg
Just a thought; making a varible public can screw things up, but it's also kind of annoying to write getters for every variable.
You only have to write setters on varibles which needs to be checked ( like to insure you are passing in corry object type to the object.
code along the lines of
PHP Code:
class Obj
{
protected $example;
function setExample( $value)
{
$this->example = $value;
}
}
is bad design in my opion.
PHP Code:
class Obj
{
public $example;
}
is more suited for the purpose.
I think setter should be used like
PHP Code:
class Obj
{
private $exampleDB;
function setExampleDB( $valueDB)
{
if( ! $valueDB instanceof ClassDB )
return 'Invalid DB';
$this->example = $valueDB;
}
}
Bookmarks