I am using Eclipse Helios Version as an IDE and developing code using
Java.
The good thing for me is that the code works well, but the bad thing is that the code doesn't look good ( I mean spaces and brackets used in control structures used in if-else statments as well as for and while loops scattered here and there )
I have used Ctrl + Shift + F , as well as an online tool (http://www.prettyprinter.de/) for formatting , and with this it looks more worse.
As a lot of developers are out here, how do you arrange your code properly and how you make it look good.
Please tell me , I am worried as some senior person might review the code .
Try to change Window->Preferences->Java->Code Formatter->LineSplittin-> Maximum Line length up to 120 or 140 symbols.
To change the settings of the code formatter, go into the following menu:
- Windows
- Preferences
- Java
- Code Style
- Formatter
And then create your own format in however a form you choose.
You can install PMD and FindBugs plugins.
The PMD tools can help you to optimize code.
The quote:
PMD scans Java source code and looks for potential problems like:
Possible bugs - empty try/catch/finally/switch statements
Dead code - unused local variables, parameters and private methods
Suboptimal code - wasteful String/StringBuffer usage
Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
Duplicate code - copied/pasted code means copied/pasted bugs