DEV Community

Discussion on: Avoid getters and setters whenever possible

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Very good write up. I had an undefinable suspicion about getters and setters, but you've helped cement it for me. Thanks for the much-needed kick in the teeth for us OOP purists! :)

I'd like to add to this, if you are only using a class/object for storing data, you've got bigger design issues than just getters and setters. Read Pseudo-Classes and Quasi-Classes
Confuse Object-Oriented Programming
by Conrad Weisert.

Collapse
 
aminmansuri profile image
hidden_dude

Getters/setters are not OO constructs.. they are inherited from "construction by parts" popularized by languages such as VB and PowerBuilder.

You'll find no such horrors in the old smalltalk codebase (though VisualAge for Smalltalk did have properties because it was a construction by parts system).

So if you were an OO "purist" you would have long eschewed getters and setters.

Collapse
 
codemouse92 profile image
Jason C. McDonald

Fair point. OOP, as Alan Kay (Smalltalk) envisioned it, is nothing like what we have today.

Thread Thread
 
aminmansuri profile image
hidden_dude

Thanks for the paper by the way.. very interesting.

Collapse
 
scottshipp profile image
scottshipp

Thanks for this paper Jason! It is great!