[ http://issues.apache.org/struts/browse/SHALE-66?page=all ]
Craig McClanahan moved STR-2293 to SHALE-66: -------------------------------------------- Project: Shale (was: Struts Action 1) Key: SHALE-66 (was: STR-2293) Component: (was: Sandbox) Version: (was: Unknown) Assign To: (was: Struts Developer Mailing List) > [shale] org.apache.shale.Constants breaks OOP > --------------------------------------------- > > Key: SHALE-66 > URL: http://issues.apache.org/struts/browse/SHALE-66 > Project: Shale > Type: Bug > Environment: Operating System: Windows XP > Platform: PC > Reporter: Dakota Jack > Attachments: Constants.java, Constants.java, ShaleConstants.java, > ShaleConstants.patch > > 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 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]