views:

67

answers:

3

I have a file with nested classes, but it's becoming long enough to be unreadable. Is there a way I can break out the nested classes into separate files?

+3  A: 

I'm afraid not.
As an alternative, you could consider converting some of them to plain Java classes: although nested classes increase encapsulation, you can certainly create good OO design without them.

My two cents.

Nikita Rybak
encapsulation - FTFY.
slomojo
@slomojo oops :)
Nikita Rybak
+6  A: 

Use the right tools.

alt text

BalusC
+1 I love me some IDE goodness.
BoltClock
NetBeans: Right click class -> Refractor -> Move Inner to Outer Level
TheLQ
...although technically this isn't what I asked for (as Nikita pointed out), this is in fact what I wanted.
Goose Bumper
You're welcome.
BalusC
Or press F6 when your cursor is over the class name in IDEA, which is the right tool.
Ricky Clarkson
@Ricky: That's indeed another right tool.
BalusC
+1  A: 

Write unit-tests to cover the code you are going to refactor.

Then use refactoring tools, e.g. Eclipse/JDT to extract each class. Run the tests for each refactoring job.

For extra fun, you can do this without the unit tests.

slomojo