Common Style Points - TheShubham99/Terasology GitHub Wiki
In the interest of not repeatedly making the same points about our code style, here are the common issues. Although these comprise the "FAQ of style" it is by no means an exhaustive list. More information on contributing to Terasology in an effective manner can be found in the main contributor workflow guide.
Starred Imports
Strictly avoid star imports in all cases
A number of IDE's by default collapse imports into the star format. For instance, a collection of imports such as
import java.util.List;
import java.util.Set;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Optional;
import java.util.Arrays;
would be condensed down to
import java.util.*;
Whilst this is shorter code, it has a few drawbacks. For these reasons we strictly avoid star imports.
Of note is that IntelliJ is known to not behave nicely when it comes to disabling this. There are details on how to disable it in this stack overflow QA
Descriptive Variable Names
Almost all variables should have descriptive names
A single letter variable is almost always not a descriptive name. This means that a developer should be able to isolate a proportion of the code and have a rough understanding of what each variable does. This does not require long and complicated names, but primarily means that a variable should be a complete word.
There are reasonable exceptions to this such as using i
as a variable in a for
loop.