private methods: your opinion wanted

goran.hultgren at bluefish.se goran.hultgren at bluefish.se
Wed Aug 28 10:25:36 UTC 2002


Hi all!

<yampa at mindspring.com> wrote:
> Squeak has a way to create private methods by using a method name with "pvt"
> at the beginning. About six methods actually use this, so it isn't common.  
> 
> I am working on some code that I will release to the public.  I expect that
> the code will be used and modified by more than just myself. I think private
> methods would help with maintaining the code, and understanding it, especially
> for those who didn't write the code. But so few programmers have used private
> methods that I wonder if Squeakers care about it, or would find it distracting
> if they see it in one place and almost nowhere else in the image.

Personally I use either "private" in the method comment and/or a method
category called "private" or several called "private yaddayadda".

One of the things I have learned during the years is that it is almost
impossible to guess what future users of a class will do with it and
thus to try to force rules of "privateness" onto future uses/users is
generally a bad thing IMHO.

But informing that a method hardly is useful outside the class and
actually could mess things up is a Good Thing. Sometime I even have
categories called "public yadda" or "public" to try to show what the
important external protocol is.

>  So my question is, should I create public/private methods for this code?  
> 
> Doug R.

It would seem to me that embedding the attribute of "privateness" in the
message selector is a bad move. It will be much harder to change later
(compared to message categories) and could break code. But I have never
used the mechanism in question so don't listen to me. :-)

regards, Göran



More information about the Squeak-dev mailing list