ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard S. Hall" <he...@richardhall.net>
Subject Re: Multiple classes in a single file (was: Re: Can someone tell me what is so great about Ant?)
Date Fri, 09 Feb 2001 08:52:24 GMT
I never meant for multiple classes in a single file to become a discussion
topic, I was just mentioning a problem I was experiencing with Ant, but since it
did become a topic let me ask a question (and since this is off topic, please
respond to me directly).

Assume I have a public class called Public and it has exclusive access to a
class called Exclusive.  My original thoughts were this, there are three ways to
implement this:

  1. In separate .java files.  This is bad because other classes can have access
     to Exclusive.
  2. As an inner class of Public.  This is bad because it provides "friend"
     access to Exclusive on Public; this is actually worse in my opinion than
     the first solution because it may lead to unintended coupling as the
     classes evolve.
  3. As separate a class in the same file as Public.  This is good because it
     eliminates the "friend" problem and the compiler complains if anyone else
     tries to access the Exclusive class.

As a result of these options, I chose the third because it seemed like the
"best" design choice.  In talking to a colleague, he had a suggestion that had
not dawned on me.  He suggested implementing Exclusive as a "static" inner
class, thus it wouldn't have "friend" access to instance variables.

This actually seems like it solves all the problems, so the question is, how do
other people deal with this design issue?

-> richard


Mime
View raw message