Try and follow a consistent pattern.
For example imagine a web application that managed media clips. Many of the controllers and screens required a parameter to be passed to them to identify the ID of the media in question. Because these individual development tasks were coded by various people, some used “mediaId”, others “id”, others “mid”, some “mediaID” with no consistency. It was difficult at times to tell if they referred to the same thing.
String mediaId = request.getParameter(“media_id”);
:
url.append(“&mID=” + mediaId);
:
Instead a simple class was written to describe the few parameters that were used in many places.
public class RequestParameters
{
public static final String MEDIA_ID = "mediaId";
public static final String APPLICATION = "app";
}
..and in the Controllers/Servlets/Actions the result showed clarity that the two values were related.
String mediaId = request.getParameter(RequestParameters.MEDIA_ID);
:
url.append(“&” + RequestParameters.MEDIA_ID + mediaId);
:
Much cleaner.
Exception: No need to over engineer the RequestParameter class. No need to define every possible request parameter unless they are used in more than one screen.