- #1
- 2,179
- 4,209
I am currently in the middle of a three month Java programming assignment, working on the worst code I ever thought to see. It looks like it was written by a monkey who was being rewarded by hitting a giant button marked "Copy and Paste". One class file that I'm working on has over 10,000 lines of code with one method that is over 2,500 lines long!
That file is generally manipulating 11 sets of variables but, they chose to create individually named variables like entry1, entry2, entry3, etc. Because of this, they have numerous methods like processEntry1, processEntry2, etc. where the code in each of these methods is copied and pasted from the others with just the numbers changed. :yuck: To top this off, they often have helper methods for these methods that go back to the database to retrieve data that they've already retrieved in the calling method. It almost looks like a deliberate attempt to slow the entire system to a crawl.
I've been trying to condense it down to something readable by creating List objects of the variables so that I can create single instances of these processEntry type methods. However, I've created 31 lists of variables already and still haven't gotten them all. In addition, there are public getEntry1 and setEntry1 type methods for every one of the variables (11 * 31 * 2 - 682 getters and setters and counting). This is just one of the files in a project that has the same programming style everywhere. It reminds me of the old game of Zork - You are in a maze of twisty passages, all alike...
I'm trying to do the best for the customer but, I'm getting to the point where it just isn't worth it. I have a list of bugs that they want fixed but, many of them are due to hard to track down copy and paste errors. By cleaning the code, I often fix the bugs. The question that I have is what would you do? Would you just slog it out or fix what you can and pray that the repair contract doesn't get extended?
That file is generally manipulating 11 sets of variables but, they chose to create individually named variables like entry1, entry2, entry3, etc. Because of this, they have numerous methods like processEntry1, processEntry2, etc. where the code in each of these methods is copied and pasted from the others with just the numbers changed. :yuck: To top this off, they often have helper methods for these methods that go back to the database to retrieve data that they've already retrieved in the calling method. It almost looks like a deliberate attempt to slow the entire system to a crawl.
I've been trying to condense it down to something readable by creating List objects of the variables so that I can create single instances of these processEntry type methods. However, I've created 31 lists of variables already and still haven't gotten them all. In addition, there are public getEntry1 and setEntry1 type methods for every one of the variables (11 * 31 * 2 - 682 getters and setters and counting). This is just one of the files in a project that has the same programming style everywhere. It reminds me of the old game of Zork - You are in a maze of twisty passages, all alike...
I'm trying to do the best for the customer but, I'm getting to the point where it just isn't worth it. I have a list of bugs that they want fixed but, many of them are due to hard to track down copy and paste errors. By cleaning the code, I often fix the bugs. The question that I have is what would you do? Would you just slog it out or fix what you can and pray that the repair contract doesn't get extended?