Naming Conventions¶
Naming conventions is another one of those things that are fun to learn working with a new codebase. We tend to follow normal Java naming for things; we have had some fun with unicode variable names over the years so please be careful and think of others.
Naming Files and Directories¶
GeoTools makes use of the following naming conventions.
Directory
ext/validation
Directory names shall be all lower case with no spaces.
Package
org.geotools.filter
Packages are all lower case with no spaces and should be located in org.geotools package
Interface
DataStore
GeoTools interfaces are usually located in the gt-api or gt-main modules. Interfaces should be called
XXX.java.Implementation
ShapefileDataStoreAppend the name of the interface being implemented
Default
DefaultQuery,QueryImplDefault implementations should be called
DefaultXXX.javaorXXXImpl.javaAbstract
AbstractDataStoreAbstract implementations should be called
AbstractXXX.javaJavadoc
doc-files/package-info.javaJavadoc makes use of
doc-filesdirectories in the package hierarchy to allow the inclusion of rich content in generated api documentation.JUnit
test-data/JUnit test cases make use of test-data directories in the package hierarchy
Test
SampleTestJUnit test, picked up by maven build process
online test
ServerOnlineTestJUnit test making use of line resource such as a web service
Some versions of windows do not distinguish between upper and lower case, and in unix, writing spaces in filenames is painful.
Notes:
Keep in mind
package-info.java,test-dataanddoc-filesdo not follow the Java naming convention allowing them to be easily distinguished from normal code.both Test and OnineTest are picked out by the maven build process for special treatment
Naming Conventions¶
We tend to follow normal java development naming conventions. Classes start with Capital letters and use CamelCase, variable start with a lower case letter and use camelCase, constants and enumerations are ALL_CAPITALS etc..
Interface
RendererUse camel case and start with a capital letter
Interface
RendererFactoryWhen defining an interface you often need a factory to handle construction
Class
DefaultRendererUse camel case and start with a capital letter. Try and end with the interface name
Class
RendererImplUsed to quickly implement an interface when we expect only one implementation
Variable
xDeltaStart with lower case using camel case to separate words
Constant
MAX_LIMITUse all capitals and an underscore to separate words. This applies to enumeration constants as well
Tools that can Help¶
Running these static analysis tools on your code will find all sorts of mistakes; in addition to checking that your names follow accepted practice.