DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32341>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32341

           Summary: Shale org.apache.shale.Constants breaks OOP
           Product: Struts
           Version: Unknown
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Unknown
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I would suggest that org.apache.shale.Constants be changed from:

public interface Constants {
}

to:

public class Constants {
  private Constants() {}
}

in order to comply with OOP requirements.  The internal use of a constant is an
implementation detail and implementing a constant interface causes this
implementation detail to leak into the exported API.  There are lots of reasons
not to use a constant interface, see Item 17 in Joshua Block's "Effective Java".
 Also, we might want to create a map for the constants here as is typically
done,  for example:

public class Constants {
  private Constants() {}



  public static Map getConstantsMap() {
    Map propMap = null;
    try {
      Field[] allFields = Constants.class.getDeclaredFields();
      int numFields = allFields.length;
      propMap = new HashMap(numFields);

      for(int i = 0; i < numFields; i++) {
        Field f = allFields[i];
        int mods = f.getModifiers();
        if(Modifier.isPublic(mods) && 
           Modifier.isStatic(mods) && 
           Modifier.isFinal(mods)) {
          String name  = f.getName();
          Object value = f.get(null);
          propMap.put(name, value);
        }
      }
    } catch(IllegalAccessException iae) {
      // log code
    }

    return Collections.unmodifiableMap(propMap);
  }
}

I hope this is an appropriate place for Shale suggestions.  I don't want to find
myself in the wrong places again.

Jack

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to