| Thread Closed |
Worst coding ever - what to do? |
Share Thread | Thread Tools |
| Nov7-09, 06:19 AM | #1 |
|
|
Worst coding ever - what to do?
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. 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? |
| Nov7-09, 08:24 AM | #2 |
|
|
I would ask them for the original program specification, then ask them if they want me to re-write the program. That sounds easier than what your having to do.
|
| Nov7-09, 10:38 PM | #3 |
|
|
I interned for a year at a software engineering firm. I have yet to see readable, nice, non-redundant code.
My job turned into what you are doing now, which is why I quit. Sometimes something you love to do as a hobby isn't the best choice for a job. I suggest you power through it if you really like designing/writing computer programs/web applications/what not, and you want to do it for a career. It will pay off in the end, for sure. But if you were like me and it was just kind of a 'hobby', then give it some thought. I still write code, and I still love it. I just love seeing my own code. |
| Nov8-09, 04:28 AM | #4 |
|
|
Worst coding ever - what to do?
Yesterday, I finally got enough variables reorganized to tackle the 2500 line method. After I had rewritten it, it was only 90 lines of code - two nested loops doing the same thing over and over.
I know that I will slog it out. I mostly just needed to vent after 7 weeks of rewriting. I actually like programming and the company that I work for. It just amazes me though how bad software can get sometimes. I do have a better project waiting for me in January that will be all new code that I will have a hand in designing, so I will look forward to that. |
| Nov9-09, 06:52 AM | #5 |
|
|
> Yesterday, I finally got enough variables reorganized to tackle the 2500 line method. After I had rewritten it, it was only 90 lines of code - two nested loops doing the same thing over and over.
That sounds scary. If they can be that bad, presumably the rest of it is just as amateur. |
| Nov9-09, 07:31 AM | #6 |
|
Admin
|
|
| Nov9-09, 08:40 AM | #7 |
|
|
|
| Nov9-09, 09:01 AM | #8 |
|
|
You beat me to it David
|
| Nov10-09, 03:57 AM | #9 |
|
|
|
| Nov10-09, 09:53 PM | #10 |
|
|
Your post made me smile. Sorry about that. Might I suggest that you archive a copy of this crap in case you ever get to teach programming. And awful as it is, this kind of disgust has helped reform some of my own tendency towards laziness. But code that smells that bad--I'd leave the job unless I were hungry enough.
|
| Nov10-09, 09:54 PM | #11 |
|
|
P S - It's a rare client or manager who will let you rewrite what needs to be rewritten. Unless they are themselves programmers and have been through it, it's very difficult to get them to understand the issues.
Good luck with that. |
| Nov11-09, 04:15 AM | #12 |
|
|
BTW, the code has now been broken down into two classes that are each 1000 lines long - still longer than I would like. All of the variables, getters and setters are in one class and the business logic is in another. Much easier to see what it does. I've already found several more issues that explain other frustrations that the customer had, so that should further justify what I've been doing. |
| Nov11-09, 04:18 AM | #13 |
|
|
I just noticed that I've been listening to a song entitled "Search and Destroy". How appropriate.
|
| Nov13-09, 01:10 PM | #14 |
|
|
This code just gets better all the time. Now that I've cleaned it up, I found yet another set of bizarre coding hoops. One page has up to 11 tables being displayed with results from a search. Each table alternates in color (yellow, blue, yellow, blue, etc.). The coder wrote a set of variables along with their getters and setters to track the data in each of the tables - dataSet1, getDataSet1, setDataSet1, dataSet2, getDataSet2, setDataSet2, etc.
This is bad enough but they decided to take it a step further. They also created another set of variables with names like dataSet11, getDataSet11, setDataSet11, dataSet21, getDataSet21, setDataSet21, etc. Why? So that they could store the yellow records in the first set and the blue records in the second set. They then had a whole pile of convoluted logic on the server side that was trying to guess where they had put the data. How can someone be so dumb?
|
| Nov17-09, 11:39 AM | #15 |
|
|
I also decided to just add blog entries for any other gems that I may find. Today's had me on the floor laughing. |
| Nov17-09, 11:49 AM | #16 |
|
|
|
| Nov17-09, 12:47 PM | #17 |
|
|
> Today's had me on the floor laughing.
A big step up from crying :) |
| Thread Closed |
| Thread Tools | |
Similar Threads for: Worst coding ever - what to do?
|
||||
| Thread | Forum | Replies | ||
| Need help coding with TI-89. Int{sin(x),x,0,inf} | General Math | 6 | ||
| computer coding | Programming & Comp Sci | 8 | ||
| Coding and GF(2) | Set Theory, Logic, Probability, Statistics | 1 | ||
| Need PHP coding help | Computing & Technology | 4 | ||
| Coding Theory | Set Theory, Logic, Probability, Statistics | 4 | ||