4 ms·
Getters/setters are important when the data structure is used from a different linkage unit than where it is defined, and binary compatibility across versions i
by jwatte 10y ago
Getters/setters are important when the data structure is used from a different linkage unit than where it is defined, and binary compatibility across versions is important.
That doers happen, but usually in fewer cases than most intermediate programmers realize. Instead, they see cases where it is used for real (like winforms or Direct3D) and cargo cult it into all code they write.
- blahedo 10y ago> they see cases where it is used for real (like winforms or Direct3D) and cargo cult it into all code they write. And a lot, a lot, of my CS prof colleagues believe it is deeply important, for reasons most of them are unable to articulate, that in an intro CS1 class all instance variables be private and accessed only through getters and setters. This is actually baked into the College Board's course description for AP CS A, and a point or two (out of 80) often hinges on it in every exam, so it is near-universally taught in high-school level CS classes (in the US). Sigh.
- deleted 10y ago[deleted]
- qwertyuiop924 10y agoSo I have to write BS for AP CS A, and I have to do it in a bad language, and we'll never get Python or Lisp? Okay, College Board, I warned you... smack this is for the above. smack and this is for teaching CS poorly in general. smack and this is for making us all by overpriced graphing calculators, thus keeping demand high...
- quotemstr 10y agoThe kinds of things you need to do in order to maintain a stable ABI are not the kinds of things you should apply to all parts of your program. That way lies madness. BTW, you don't need accessors even for public ABIs. stat(2), for example, doesn't need "accessors" for struct stat and it's been stable for decades. The same idea applies to Win32 core APIs.