Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel-eecis!news.mathworks.com!news-res.gsl.net!news.gsl.net!swrinde!news.sgi.com!spool.mu.edu!howland.erols.net!vixen.cso.uiuc.edu!newsfeed.internetmci.com!newsxfer2.itd.umich.edu!portc01.blue.aol.com!newsstand.cit.cornell.edu!news.acsu.buffalo.edu!news.drenet.dnd.ca!crc-news.doc.ca!nott!cunews!revcan!macdonald!news
From: 000826b@dragon.acadiau.ca (Michael Barkhouse)
Subject: Re: views sought on use of accessors/mutators
Content-Type: Text/Plain; charset=US-ASCII
Organization: Revenue Canada
Date: Thu, 8 Aug 1996 21:08:04 GMT
Message-ID: <Dvu81G.BMr@revcan.ca>
Mime-Version: 1.0
X-Newsreader: WinVN 0.99.7
References: <4uaq1q$o6h@linus.mitre.org> <4ub5nb$pkj@vnetnews.value.net>
Sender: news@revcan.ca (USENET News)
Nntp-Posting-Host: batman.revcan.ca
Lines: 27

>One of the strong points of the OO paradigm, is encapsulation. By
>using accessors/mutators for each instance variable, I believe it
>takes this "encapsulation paradigm" down to its finest level. If you
>were to access/mutate an attribute of an object, all over the place,
>then you lose that, and makes it harder to debug your Objects.

Encapsulation is one of the parts of the OO paradigm and by using accessors you are directly 
violating this. Even though I know this to be true, I will use accessors with classes I create 
too. It is just a matter of principle. Accessors really only violate encapsulation if they're 
used (this could be argued, but that is how I see it). It is up to the programmer to use them 
only where appropiate.

>
>The best way, to stop other developers of not accesing parts they are
>not allowed to, is to put comments in your method and state clearly
>the use of each method, and whether is private or public. If you state
>that a method is private and somebody else uses it from outside to
>carry a task, then he is at fault. This is where projects/companies
>have to enforce standards/guidelines for development, and not just to
>depend blindly on the tools.

That's exactely how I see it too. When you create a class, if you don't want other classes to 
use these methods then put them in a protocal called private. This is practiced by most 
smalltalk programmers.

Mike

