Answering your questions
- Is it OK to put constants to interface and use them in the implementation?
Certainly, so long that it makes sense for them to 'belong' to the interface.
- Should I make constants static final if they are defined in an interface? Which constants should I prefer, int or String?
As mentioned in @VoiceOfUnreason's answer, sometimes you should consider enum
s instead of 'plain' int
and String
values. Enum
s are usually more expressive and thus a better fit for enumerated values. Constants should always be declared as static final
to communicate the intent that they are unmodifiable, and that they can be used without class instantiation.
- Can I make some additional actions in setters?
The idea here is to be consistent. If your setEmployer()
method calls signRenumerationPackage()
and the optional (I hope) burnBridges()
methods, then you have to make sure modifying the employer reference always goes through the setEmployer()
setter. As long as you have consistency in place, having additional actions in setters are OK and sometimes even encouraged.
- When should I write a JavaDoc?
As early as possible. :)