Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!media03!pkr From: pkr@media03.UUCP (Peter Kriens) Newsgroups: comp.lang.smalltalk Subject: Re: Access methods - New feature ? Message-ID: <2273@media03.UUCP> Date: 25 Apr 91 08:11:48 GMT References: <1991Apr21.221149.8057@vuse.vanderbilt.edu> <1991Apr23.010026.25098@ccs.carleton.ca> Reply-To: pkr@media03.UUCP (Peter Kriens) Organization: aQute, Netherlands Lines: 30 voss@cs.uiuc.edu (Bill Voss) writes (after giving an example about point not using x,y for calculating the distance between two points) Now is it ALWAYS wrong to use access methods? I do NOT contend that it is ALWAYS wrong.v:Soon I think it must be judged on a case by case basis. However, I do contend that it is USUALLY wrong. 1: I think a basic quality of object oriented design is defining a "functionality" only in place. Calculation of the distance between points should therefore be placed in one location and that is the Point class. Your example violates this first rule. I cannot in the world see what this example has to do by accessing through a method of the instance variable. 2: Instance variables have a natural tendenncy to contain the most relevant information regarding an object. So it seems quite natural to me that they should be accessible outside the object. What I dont want is that once I change the implementation (e.g. change a Point from x,y to polar coordinates) that my clients break. As long as the instance variables are accessed through methods (and i dont seen another way to do it in Smalltalk) I can always keep the same interface. So what is wrong in have the instance variable access methods? 3: I do not promote to make EACH instance variable automatically accessible, but I think it would be very nice to allow variables to be exported like in Eiffel. Peter Kriens pkr@media01.uucp