I would like to use 'default' as a variable name. Is there a code convention (like class -> clazz) that suggests how I should name the variable?
I usually add a term that indicates for what it is the default. So I'd use defaultName
or defaultPermission
or possibly defaultValue
(only if the meaning is clear for the context).
One more thing: if it is a fixed value - a constant instead of a variable - make it final or even static final/public static final and keep it as class member instead of a local variable. You should write constants upper case.
public class MyClass {
public static final String DEFAULT_NAME = "MyApplication";
public String name;
public MyClass() {
this.name = DEFAULT_NAME;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With