wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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.
 
Don't get me started about those stupid light bulbs.
 
subject: Interface constants - Anti pattern
 
Similar Threads
Why is interface constant static
Interface
Which one is better
Constants Class
Interface with ONLY CONSTANTS