2 ms·
Frameworks elevated the need for getters and setters, given the need to programmatically access the internals of objects. Their overuse is also a consequence o
by aryehof 9y ago
Frameworks elevated the need for getters and setters, given the need to programmatically access the internals of objects.
Their overuse is also a consequence of the popularity of a programming style of code acting on data, typically within an application that has class data merely representing database entities, acted on by separate logic and constraints in an application/service layer. Behavior based object design seems to be an endangered species.
- cultvoid 9y agoExactly this. If you're working on a system with any need of serialization (eg to/from JSon), or presentation on some kind of view tier, or storage in a database, then the frameworks make get/set pairs inevitable, even if you fight tooth and nail not to have them. (Of course you could avoid the frameworks, but try telling your project managers that). Behavior based object design, as well as being an endangered species, probably never existed very much in the first place. I wonder if Java's popularity was partly due to people being able to appear to do OO whilst actually implementing "code acting on data" systems. You got the warm OO glow without the hard work of doing any behavior driven design.