Re: Something like import/package in java?



On 30 Jun 2008, at 19:19, Michael Morin wrote:

Christoffer Lernö wrote:
What I'd love to have is something like this instead of require:
<logio.rb>
package commands
class LogIn
...
end
class LogOut
...
end
end
<main.rb>
import commands.LogIn
where import goes into the commands dir and just loads that single
class.
Is there something like this available? Any ideas?
/C

Not really. If you're worried about namespace pollution, you can
put everything into a module. Besides including the module and
"importing" everything within it, I don't think there's a way to
selectively include classes or methods from the module.

What exactly are your concerns? Neatness aside.

Readability, clear division of responsibilities, ease of development.

- Even with unit test suites I don't feel secure that the test isn't
conditional on files included by other tests.
- If I want to include all classes from a dir, I have to manually scan
through the dir.
- Clear cut organization of files.
- Crystal clear dependencies between files.
- Lots of other small worries I can't quite put my finger on.

There's some breaking point around 20+ files for me (excluding unit
tests), when it becomes really important to have a well-defined
organization of my classes, and here just heaping classes into
different files doesn't quite cut it for me.


/C
.