The Artima Developer Community
Sponsored Link

Question about method names

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Question about method names

Posted by John D. Heintz on 10 May 1998, 8:43 AM

I think this question is at least slightly related to
your column and find it to be the challenging part for
me in arranging my code into methods.

My question is how to you name private methods differently
than public methods?

To use your doSomething(Component c) example, suppose
we wanted:


public void doSomething(Component c) {
if(c.isVisible()) {
//call some private method
} else {
//call some other private method
}
}

Now what should we name the private methods?
Verbose names could be:
private void doPrivateSomethingNotVisible(Component c);
and
private void doPrivateSomethingVisible(Component c);

This is a little long for my taste, but clear. Is
adding the "Private" qualifier good?

I often find that I want a public method with a name
and I private one(s) with the same name, where the
public method uses queries to handle control
and requirements rules while the private one(s) does
the actual work.

Sorry about the rambling nature of this posting, I
haven't thought about this issue clearly enough to
write about it well.

Thanks,
John



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us