-
Enhancement
-
Resolution: Fixed
-
P4
-
7
-
b27
-
generic
-
linux
-
Not verified
Prior to Java 5, there was an ugly approach in using constant values named as Constant Interface Antipattern. To keep constants at one place and make them accessible in different classes of the application, it was a custom to define an interface containing all constants, other classes had to implement the interface wherever those constants were required.
This approach conflicts with the object orientation of Java language. Such constants are implementation details for a class but if the class accesses them by implementing an interface they become a part of public access (API) of the class. It means implementation details are being linked as API here.
Constant imports could be used as a replacement.
This approach conflicts with the object orientation of Java language. Such constants are implementation details for a class but if the class accesses them by implementing an interface they become a part of public access (API) of the class. It means implementation details are being linked as API here.
Constant imports could be used as a replacement.