The Daily WTF
Follow
Representative Line: One More Parameter, Bro
Matt needed to add a new field to a form, but the task was complicated by the method used to save changes back to the database. The method, saveQualif, had 36 string-typed parameters, which made it difficult to work with. The method created a data access object with the same number of parameters and updated fields in the database if they were non-null. The parameters included sensitive information like pdfPassword, which was stored in plain text. The method was called twice, once with all parameters filled in and once with most parameters set to null. Matt was tempted to refactor the method to make it better, but he was concerned about breaking something and decided to add another parameter instead. This approach has been taken by previous developers, who have also avoided refactoring the method. The result is a complex and difficult-to-maintain codebase. Refactoring is often put off until later, leaving it for future developers to deal with. This approach can lead to problems down the line, such as errors and security vulnerabilities.