Reputation: 66575
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?
Upvotes: 9
Views: 16107
Reputation: 201
This works in netbeans:
// <editor-fold defaultstate="collapsed" desc=" Region Name ">
... Enter Code Block here ...
// </editor-fold>
Upvotes: 20
Reputation: 9203
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.
Upvotes: 2
Reputation: 351688
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.
Upvotes: -1
Reputation: 328780
In Java, you use packages and projects to organize your code.
Upvotes: -2
Reputation: 14448
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.
Upvotes: 7