Eclipse Project Rules
- To avoid name clashes with external projects, all my code is under the top-level package ‘goedegep’.
- Each Eclipse Project has a single top level package, e.g. ‘goedegep.util’.
- Eclipse Project names are the same as the single top level package of that project.
- Subject
I use the term subject to describe functionality like goedegep.finan. A subject may have a data model and/or an application. - Data models will be in a ‘model’.<subject> sub-package (e.g. goedegep.model.rolodex) and applications in an <subject>.‘app’ sub-package (goedegep.rolodex.app).
Note: I use this for the time being, because it’s easy to have the ecore file name in line with the subject, instead of all ecore files having the name model. - All projects follow the ‘maven structure’, so the java source code is under src/main/java.
Maven rules
- The Maven groupId is equal to Subject, except for data models.
- The Maven artifactId is equal to the Eclipse Project name, where dots are replaced by hyphens.
This has to be a qualified (long) name like this, as it is the name of the created jar file.
Java rules
Naming rules
- Utility classes
The names of utility classes end with ‘Util’ (and not ‘Utils’).
For example the URL utilities class will be named ‘UrlUtil’.
Logging
For logging, java.util.logging
is used.
Logging is initialized by calling logSetup()
in goedegep.appgenfx.JavaFXApplication
(which is extended by each application). This installs a goedegep.util.logging.MyLoggingFormatter
.
Every class defines its own logger of type java.util.logging.Logger
:
private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName());
Argument precondition checking
For checking the preconditions on the arguments of a method, use the functionality provided by the java.util.Object class. Examples:
this.customization = Objects.requireNonNull(customization, "argument 'customization' must not be null");