dagblog.
← Archive

Java coding conventions


Over time, most programming languages develop conventions
 for writing source code. Some are formal and some informal. 
 Informal conventions usually evolve naturally as people move between
languages.

In his post How to write identifiers in Java and C# , Tomáš Kouba points out the basic conventions for identifiers and considers using accented characters in their names. Personally, I wouldn’t use Czech characters. I’m glad the option exists, though. Some programmers will surely use it.

Take conventions seriously

Back in Java, formal conventions cover more than identifiers. The Java 
Code Conventions
document describes things like comment formatting, filenames and their 
organization, indentation, and block declarations.

The Java Code Conventions are a comprehensive document every Java developer should revisit from time to time. I think they’re especially valuable when writing, or more precisely sharing, code on a team. When everyone internalizes the same rules, the team can work much more efficiently.

There may even be small departures from the Java 
Code Conventions
. Those can become informal conventions in general use or formal rules within a development team. One such convention might be to prefix interface names with I (IOsoba), or to suffix their implementations with Impl (OsobaImpl).

Medium version

Related articles

Related CZ Podcast episodes