title: Interfaces with static fields in java for sharing 'constants'
body: <p>I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface.</p>
  
  <p>For instance, <a href="http://www.processing.org" rel="noreferrer">processing.org</a> has an interface called <a href="http://dev.processing.org/source/index.cgi/tags/processing-1.0/core/src/processing/core/PConstants.java?view=markup" rel="noreferrer">PConstants.java</a>, and most other core classes implement this interface. The interface is riddled with static members. Is there a reason for this approach, or is this considered bad practice? Why not use enums <em>where it makes sense</em>, or a static class?</p>
  
  <p>I find it strange to use an interface to allow for some sort of pseudo 'global variables'.</p>
  
  <pre><code>public interface PConstants {
  
    // LOTS OF static fields...
  
    static public final int SHINE = 31;
  
    // emissive (by default kept black)
    static public final int ER = 32;
    static public final int EG = 33;
    static public final int EB = 34;
  
    // has this vertex been lit yet
    static public final int BEEN_LIT = 35;
  
    static public final int VERTEX_FIELD_COUNT = 36;
  
  
    // renderers known to processing.core
  
    static final String P2D    = "processing.core.PGraphics2D";
    static final String P3D    = "processing.core.PGraphics3D";
    static final String JAVA2D = "processing.core.PGraphicsJava2D";
    static final String OPENGL = "processing.opengl.PGraphicsOpenGL";
    static final String PDF    = "processing.pdf.PGraphicsPDF";
    static final String DXF    = "processing.dxf.RawDXF";
  
  
    // platform IDs for PApplet.platform
  
    static final int OTHER   = 0;
    static final int WINDOWS = 1;
    static final int MACOSX  = 2;
    static final int LINUX   = 3;
  
    static final String[] platformNames = {
      "other", "windows", "macosx", "linux"
    };
  
    // and on and on
  
  }
  </code></pre>