java - What is the best way to define a set of constants in a web project? -
this question has answer here:
- what best way implement constants in java? 27 answers
i'm working on ejb project , need define set of constants can use in whole of project create interface hold set of constants question there better way in define constants in web project ?
this exemple of constant interface :
public interface ejbconstant { final string const23= "ab23"; final string const24= "ab24"; // .......... }
thank suggestion
sonar has quite explanation of examples
according joshua bloch, author of "effective java":
the constant interface pattern poor use of interfaces.
that class uses constants internally implementation detail. implementing constant interface causes implementation detail leak class's exported api. of no consequence users of class class implements constant interface. in fact, may confuse them. worse, represents commitment: if in future release class modified no longer needs use constants, still must implement interface ensure binary compatibility. if nonfinal class implements constant interface, of subclasses have namespaces polluted constants in interface.
Comments
Post a Comment