From: Sal on
I have a directory that contains many classes in the same package and
a program that uses just one of those classes. Is there any advantage
to moving that program outside the directory and import only the class
it needs over keeping it in the directory and making it part of the
same package, eliminating the need for the import?
From: Arne Vajhøj on
On 19-06-2010 11:49, Sal wrote:
> I have a directory that contains many classes in the same package and
> a program that uses just one of those classes. Is there any advantage
> to moving that program outside the directory and import only the class
> it needs over keeping it in the directory and making it part of the
> same package, eliminating the need for the import?

I am not quite sure that I understand the question.

But anyway:
* directory structure and package structure should match
* package structure should reflect the logical structure
in your software
* full name vs import vs same package is only relevant at compile
time - at runtime all classes are referenced using full names

Arne


From: Lew on
Sal wrote:
> I have a directory that contains many classes in the same package and
> a program that uses just one of those classes. Is there any advantage
> to moving that program outside the directory and import only the class
> it needs over keeping it in the directory and making it part of the
> same package, eliminating the need for the import?

No.

There isn't any need for the import in the first place.

Imports are compile-time occurrences only. Class load takes the same time
regardless, and is on demand. If a class is used, it's loaded at runtime.

If the "just one" class uses any of the other classes in that package, they'll
get loaded on demand, too.

Classes don't have directories, they have packages. Class *files* are stored
in directories, though not necessarily.

--
Lew
From: Martin Gregorie on
On Sat, 19 Jun 2010 08:49:33 -0700, Sal wrote:

> I have a directory that contains many classes in the same package and a
> program that uses just one of those classes. Is there any advantage to
> moving that program outside the directory and import only the class it
> needs over keeping it in the directory and making it part of the same
> package, eliminating the need for the import?

I'd say its fine the way it is provided that the classes are only used by
one or more programs that are all part of the same package. If the list
of classes is large there may be a case for leaving the program(s) where
they are and making the classes into an inner package but I'd only do
that if it will make maintenance, etc. easier. Of course, if other
programs are likely to use the same classes, then there's a clear case
for moving the program somewhere else so the package is purely a class
library.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
From: Roedy Green on
On Sat, 19 Jun 2010 08:49:33 -0700 (PDT), Sal <here(a)softcom.net>
wrote, quoted or indirectly quoted someone who said :

>I have a directory that contains many classes in the same package and
>a program that uses just one of those classes. Is there any advantage
>to moving that program outside the directory and import only the class
>it needs over keeping it in the directory and making it part of the
>same package, eliminating the need for the import?

If you just want to use the class as is, there is no advantage. If
you moved it, you could access the default scope methods and
variables.

However, cloning a class is generally a very very bad thing to do. You
will update one and forget to update the other.
--
Roedy Green Canadian Mind Products
http://mindprod.com

There is no harm in being sometimes wrong especially if one is promptly found out.
~ John Maynard Keynes (born: 1883-06-05 died: 1946-04-21 at age: 62)