Skip to content

ghusta/java-code-conventions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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 <<. It will then be available within the current workspace.

As you can see, I don't like much the Sun or K&R style of indentation. I prefer to adopt the 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 (Souce file structure, Formatting, Naming, Programming practices, ...)
  • Chapter 5 : Formatting, in Clean Code - A Handbook of Agile Software Craftsmanship - On Amazon

About

Java Code Conventions and Formatting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published