3 ms·
The more I program the more I realize that we are all blind men feeling out an elephant. It sounds like you got the gist but somehow you are in an area of prog
by dragontamer 2y ago
The more I program the more I realize that we are all blind men feeling out an elephant.
It sounds like you got the gist but somehow you are in an area of programming where getter/setters aren't useful.
That's fine and okay. Part of growing up as a programmer is realizing your niche.
Most of the advice out there is deep, not broad. It's deeply connected with our niche and not necessarily broadly applicable.
- smt88 2y agoThis was weirdly condescending and content-free. I've been programming for 30 years, and getters/setters are both pointless and anti-productive. They hide (potentially a lot of) code from people reading the program, which leads to a lot of "wtf" moments later. Magic in general is bad, and it's the kind of "look how concise and clever I am" thinking that leads to unmaintainable software. If setting a property isn't straightforward, make it private/protected and add explicit getter/setter methods. It's more work today and much less work later on.
- hparadiz 2y agoEvery php ORM disagrees. Nothing about it is magic
- smt88 2y agoPHP ORMs and ORMs in general are notoriously hard to maintain. I've written hundreds of thousands of lines of PHP, I'm speaking from experience.
- hparadiz 2y agoI maintain an ORM [ https://github.com/Divergence/framework/blob/release/src/Models/ActiveRecord.php https://github.com/Divergence/framework/blob/release/src/Mod... ] and have also maintained a job's fully custom ORM as well. 20 YOE in PHP. Also speaking from experience :)
- keybored 2y agoIt sounds like you got the gist of the critique of getters/setters but just haven’t been exposed to the alternatives. That's fine and okay.
- hombre_fatal 2y agoGetters/setters are just as easily associated with hidden behavior that makes systems worse. The only sibling comment of yours that bothered to even show code just demonstrated how they turned user.lastPost into a method that makes a hidden DB query. Yet the benefits are supposedly so nuanced and hard to get across that merely asking about it gets a "you'll understand when you get some real experience ;)" comment from you.
- keybored 2y agoHaha as someone who doesn’t understand getters/setters as a pattern I’m bewildered by this subthread.