11 ms·
Don't you get tired of managing getters/setters in your entities?
by conradfr 2y ago
Don't you get tired of managing getters/setters in your entities?
- mgkimsal 2y agoaren't you just managing them in a new syntax now?
- joshmanders 2y agoThe difference with property hooks and userland getter/setters is that you're now just doing echo $obj->prop $obj->prop = 'bar'; not echo $obj->getProp(); $obj->setProp('bar');
- stephenr 2y agoA big part of this is about code that's consumed by third parties: i.e. library code. Previously, it was very common to not expose a public property directly, even if it required no setter logic, because any future change to add setter logic would mean it has to become a setter method. This results in potentially dozens of boilerplate getter/setter methods, that provide no actual benefit, but are necessary to avoid potential BC breaks in a future version of the library. With property hooks, the property doesn't need to define any getter/setter logic initially - and adding a hook later to the `set` action doesn't change the way other code calls it. So no, it isn't just "new syntax" now - it's a case of largely not needing to write/generate any of that boilerplate any more - it's just not needed, regardless of how that property's behaviour changes in future.
- cutler 2y agoEntities, shrentities - it's all just data.
- tcfhgj 2y agowhich getters/setters?
- whalesalad 2y agostockholm syndrome is real
- immibis 2y agoThis comment is referring to the practice of always writing getters and setters even when they are not needed, then feeling frustrated by the amount of boilerplate.