Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!mailrus!umix!umich!mibte!gamma!ulysses!andante!alice!shopiro From: shopiro@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: Critique of Wiener/Pinson Message-ID: <7820@alice.UUCP> Date: 21 Apr 88 20:31:16 GMT References: <8063@apple.Apple.Com> <6590039@hplsla.HP.COM> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 42 Summary: using access functions you can change the internal representation of a class without changing the interface. In article <6590039@hplsla.HP.COM>, jima@hplsla.UUCP writes: > If you refuse to stick to your original definition of blah, > and you make blah public, and someone uses blah, and then you change > your definition of what blah means, then that user of your class is > going to be hosed. > > BUT this is true whether or not blah is an access function or a public > instance variable. If you change your definition of what a public > anything means, you will hose your users. (This should be obvious, but ... ) Suppose you have class Complex { double re, im; public: double real() { return re; } // ... }; and you decide you want to switch to polar coordinates. Then you can write class Complex { double rho, theta; public: double real() { return ; } // ... }; and users will not be affected. > ... Change the meaning of > any part of your public interface, either instance variable or function, > and your class's users will be hosed. But use access functions so you can change the internal structure of your class without changing the meaning of its public interface. -- Jonathan Shopiro AT&T Bell Laboratories, Murray Hill, NJ 07974 research!shopiro (201) 582-4179