aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Interface constants - Anti pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Interface constants - Anti pattern" Watch "Interface constants - Anti pattern" New topic
Author

Interface constants - Anti pattern

Srinivas Ivaturi
Ranch Hand

Joined: Jan 28, 2003
Posts: 50
Hi all

I heard that we should not declare the constants in Interface to access them in concrete class which is called Anti pattern.

Is it true? If so please let me know what are the other ways where I declare constants and use them

Thanks
Srinivas Ivaturi.
Deepak Pant
Ranch Hand

Joined: Feb 13, 2004
Posts: 443
Declare them in class itself.
(a) You can create Enumeration classes to contain enum type constants. OR
(b) You can have a package level class containing constants to be used across the classes in that package.
(c) Point is that never declare the constants in the Interface. Interface is not meant for this purpose.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface constants - Anti pattern
 
Similar Threads
Constants Class
Interface with ONLY CONSTANTS
Interface
Which one is better
Why is interface constant static