views:

319

answers:

5

Hi,

While the code is growing big it is getting harder and harder to keep everything well organized. One thing I liked very much the time I developed in .NET was #region/#endregion which enabled to organize the code in logical groups and made further organization much easier.

Does anyone know whether there is any similar code organization possible in Java?

+3  A: 

That is a feature of Visual Studio, not .NET. You would have to look into your Java IDE of choice and see what options they have.

Jason Miesionczek
A: 

In Java, you use packages and projects to organize your code.

Aaron Digulla
I believe he was interested in orgainzing code within a single source file. I don't believe packages would be too helpful for that :)
luke
A: 

No, Java doesn't have anything like that. If anything you should get a better text editor that allows for arbitrary code folding or code folding based on comments.

Andrew Hare
+1  A: 

The problem with regions is they can make files filled with thousands of lines of spaghetti code look like they are compact, clean and well organized at first glance, which they are not.

If a single file is getting unmanageable, think about how you've structured your classes and is there things you can refactor out into their own classes or methods?

I got very region happy when I started .net and now I don't think I've written one in years. They lost all value in my eyes the first time I opened a file with 5 regions, thought, "Hmm...simple enough" only to expand one and get a few thousand lines of code that made no sense whatsoever.

Nick
+1  A: 

http://wiki.netbeans.org/FaqCustomCodeFolds

anonymous