Source Oddities, chapter 1 +
Java limits the number of method parameters to 255 (static methods) or 254 (non-static methods) or less if parameters are of type long or double. Fine, but this does not mean that you ever should get even near this limitation. If you ever feel the need of creating a method with more than four or five parameters then you should lean back for a moment and think again about your application design.
Methods that have too many parameters don’t communicate their intention that well which decreases code readability and potentially makes maintenance more difficult. Even worse, if parameters of the same type are used, they can be easily mixed up by accident in a method call.
Having said this, let me give you an example I stumbled upon recently while digesting the code of a webservice API that we are working with:
public User updateUser(
String userId, String password, String emailAddress,
String languageId, String timeZoneId, String greeting,
String resolution, String comments, String firstName,
String middleName, String lastName, String nickName,
String prefixId, String suffixId, boolean male, int birthdayMonth,
int birthdayDay, int birthdayYear, String smsSn, String aimSn,
String icqSn, String jabberSn, String msnSn, String skypeSn,
String ymSn, String jobTitle, String organizationId,
String locationId);
You get my point? So, we are already looking forward for the next API update, which will probably add facebookId, twitterId, flickrId, diggId, deliciousId, stumbleUponId, lastFmId, youTubeId and slideShareId to the list.
Stay tuned and may the source be with you.
Strange…somehow I see a ray of life, ahm, light, now…