https://github.com/ghusta/java-code-conventions
Java Code Conventions and Formatting
https://github.com/ghusta/java-code-conventions
Last synced: 3 months ago
JSON representation
Java Code Conventions and Formatting
- Host: GitHub
- URL: https://github.com/ghusta/java-code-conventions
- Owner: ghusta
- Created: 2014-01-21T09:56:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-21T22:58:32.000Z (over 11 years ago)
- Last Synced: 2025-01-06T22:36:01.249Z (5 months ago)
- Size: 148 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
java-code-conventions
=====================Java Code Conventions and Formatting
# General
It is often useful to adopt common code conventions, almost when working on a team or on open source projects.
In modern IDEs, the source code can also be automatically formatted, like in Eclipse.# Eclipse
### How to import a code style file ?
In Eclipse : __Window > Preferences > Java > Code Style > Formatter__
Then click __Import__ and pick a file.You can pick my code style file by example : >> [here](eclipse/eclipse-java5-codestyle.xml) <<.
It will then be available within the current workspace.As you can see, I don't like much the Sun or [K&R style](http://en.wikipedia.org/wiki/Indent_style#K.26R_style) of indentation.
I prefer to adopt the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style),
where the opening and closing braces are aligned vertically.### How to format source code ?
Right click in the source code, then __Source > Format__ (shortcut : Ctrl + Shift + F).
# Other useful references
* [Google Java Style](http://google-styleguide.googlecode.com/svn/trunk/javaguide.html) (Souce file structure, Formatting, Naming, Programming practices, ...)
* Chapter 5 : Formatting, in _Clean Code - A Handbook of Agile Software Craftsmanship_ - [On Amazon](http://www.amazon.fr/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)