re: PHP Typed Properties: Think Twice. VIEW POST

TOP OF THREAD FULL DISCUSSION
re: "First, you shouldn't be using public fields." It is cargo-cult that every OOP programmer has followed since eons. For example. public $field; ...
 

no, you've gained the option of doing anything else at the point of get and set - you can change your implementation - you can refactor your field into something different and maintain your existing interface. a public field is just that, once its there you can never remove it.

In my experience, to hide logic in the getter or setter is dangerous because nobody would expect something there (unless it is a visual object such a button or textbox). So, finally, the getter and setters are a dummy.

Proof, C# has properties, they are a dummy but they are short & easy to write.

int MyProp {set; get;}

code of conduct - report abuse