I found some brilliant code with over 30 parameters given to a method (I lost the count). The implementation contains more than 500 lines with if/then/else and switch block's.
How could this be refactored in a clean way? What would your advise be on this?
A lot of implementations are all over the application and all push these parameters.
Problem method:
public static User findUser ( String userCode, String lastName, String firstName, String alternativeLastName, String sex, int day, int month, int year, String locationParameter, String locationInfo, Id groupId, Id organizationId, Id orderId, Id orderGroupId, Id orderOrganizationId, List<Id> groupIds, List<Id> organizationIds, List<Id> orderIds, List<Id> orderGroupIds, List<Id> orderOrganizationIds, String timeRange, Long daysAgo, Date dateFrom, Date dateUntil, CodingMap codingMap, List<String> languageList, String visitType, Account account, List<Group> accountGroups, Organization accountOrganization, Profile profile, AccessProfile accessProfile, Locale locale, int maxResults, long newTimeRange, long minimumTimeRange, boolean hideUserWithoutName, boolean withOrderInfo, boolean withVisitInfo, boolean orderEntryAvailable, boolean hideDiscontinuedResults, boolean checkPatientAccessRights, boolean searchForCopies, boolean inOrderEntry, boolean allPatientCodes, boolean addPatientCharacteristics, boolean showSpeciesColumn, boolean patientDefinedWithPrivacyLevel, boolean excludePatientsWithoutCodeInSelectedCodingSystem ) throws CompanyException { ... } Used all over the place like this:
User.findUser(member.getCode(), context.lastName, context.firstName, context.alternativeLastName, context.sex, context.birthDate.getDay(), context.birthDate.getMonth(), context.birthDate.getYear(), context.locationParameter, context.locationInfo, null, null, null, null, null, null, null, null, null, null, session.timeRange(), session.daysAgo(), session.dateFrom(), session.dateUntil(), order.codingMap(), order.languageList(), member.visitType(), null, null, null, null, null, locale, 25, 1000L,200L, session.point.booleanValue(), session.infobooleanValue(), false, true, true, true, true, true, true, true, false, false, false);