Code: Select all
function property($value=null) {
if ($value!==null)
$this->field = $value;
return $this->field;
}Code: Select all
$this->field = "some value";I can see why , if you dont set
Code: Select all
var $field = NULL;
//OR
var $field = "";but still, what is the hoopla over using getters and setters versus just setting the damn thing either way ?
Code: Select all
($value !== null)?$this->field=$some_value:$this->field=null;what's the purpose? what's the theory behind it? explain to me why this *cough*Code Bloat *cough* is necessary ?
it makes absolutely no sense to me, since if a field is null, it would have to be declared to avoid notices/warnings, and if it isnt null, just set it, why use some silly contrived 6-lines-of-code-to-do-what-you-can-do-in-one getter or setter function ??
Give me some good, logical set in programming principles arguments, not "because its the way to do stuff in OOP" , which I wont listen to. I want to know WHY it is "the way do do it" , not "just because"