Worst coding ever - what to do?

  • Thread starter Borg
  • Start date
  • Tags
    Coding
In summary: The Daily WTF?In summary, this programmer is having a lot of trouble with a project that is over 3000 lines of code with many methods that are long and difficult to read. They are trying to condense the code into a list of variables, but they are having a lot of trouble. The programmer recommends that the customer power through the project, as it will eventually pay off.
  • #1
Borg
Science Advisor
Gold Member
2,157
4,139
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... :rolleyes:

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?
 
Technology news on Phys.org
  • #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.
 
  • #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.
 
  • #4
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.
 
  • #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.
 
  • #6
Borg said:
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.

Contact Guinness Book of Records, perhaps they keep track of such cases.
 
  • #8
You beat me to it David
 
  • #9
silverfrost said:
> 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.

It is.

DavidSnider said:
Submit it to The Daily WTF

http://thedailywtf.com/Default.aspx

Nice link. Thanks. I may submit it when I get the time.
 
  • #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.
 
  • #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.
 
  • #12
harborsparrow said:
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.

The customer has already expressed pleasure that I'm working on the code so, yes, I'm fortunate in that respect. I haven't told them how extensively I've been cleaning the code though. :wink:

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.
 
  • #13
I just noticed that I've been listening to a song entitled "Search and Destroy". How appropriate. :tongue:
 
  • #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? :rofl: :rofl: :rofl: :rofl: :rofl:
 
  • #15
DavidSnider said:
Submit it to The Daily WTF

http://thedailywtf.com/Default.aspx

I submitted it today. I'll update this if it gets posted.

I also decided to just add blog entries for any other gems that I may find. Today's had me on the floor laughing.
 
  • #16
Borg said:
How can someone be so dumb? :rofl: :rofl: :rofl: :rofl: :rofl:

Try not to be too hard on em. Every day I check that site I expect to see snippets from my intern days. :smile:
 
  • #17
> Today's had me on the floor laughing.

A big step up from crying :)
 
  • #18
Coding that bad is actually rather impressive. There should be an award for things like that.
 
  • #19
DavidSnider said:
Submit it to The Daily WTF

http://thedailywtf.com/Default.aspx

Borg said:
I submitted it today. I'll update this if it gets posted.

They finally printed it. http://thedailywtf.com/Articles/The-Integer-Cache.aspx" [Broken] in the comments section for anyone who's interested.

We've fixed all of the serious problems and the customer is extremely happy. I am so glad that this project is almost finished. I was afraid that some of it might rub off... :yuck:
 
Last edited by a moderator:
  • #20
Congratulations all round by the sound of it.
 
  • #21
Borg said:
They finally printed it. http://thedailywtf.com/Articles/The-Integer-Cache.aspx" [Broken] in the comments section for anyone who's interested.

We've fixed all of the serious problems and the customer is extremely happy. I am so glad that this project is almost finished. I was afraid that some of it might rub off... :yuck:
Oh that was you? I just found this thread today, I thought it sounded familiar! :rofl:

Congratulations, by the way.
 
Last edited by a moderator:

1. What are some common mistakes in coding that lead to "worst coding ever"?

Some common mistakes that can lead to poor coding include using overly complicated or convoluted logic, not following coding standards or best practices, not properly commenting or documenting code, and not testing or debugging thoroughly.

2. How can I improve my coding skills to avoid creating "worst coding ever"?

To improve your coding skills, it is important to regularly practice and learn from experienced developers. You can also read coding books and tutorials, participate in online coding communities, and attend coding workshops or classes. It is also important to constantly review and refactor your code to make it more efficient and readable.

3. What should I do if I realize I have written "worst coding ever"?

If you realize that your code is not up to par, the first step is to acknowledge the issue and take responsibility for it. Then, you can try to identify and fix the specific problems in your code. It may also be helpful to seek feedback or advice from more experienced developers.

4. How can "worst coding ever" negatively affect a project or team?

Poor coding can have a variety of negative consequences. It can lead to slower development and increased costs, as well as more bugs and errors in the code. It can also make it difficult for other team members to understand and work with the code, causing communication and collaboration issues.

5. Is it ever too late to fix "worst coding ever"?

No, it is never too late to improve your coding. Even after a project is completed, you can still go back and refactor your code to make it better. However, it is important to communicate with your team and stakeholders before making significant changes to the code, as it may affect the project timeline and budget.

Similar threads

  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
13
Views
4K
Replies
10
Views
904
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
17
Views
4K
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
23
Views
3K
  • Programming and Computer Science
2
Replies
49
Views
10K
  • Biology and Medical
Replies
1
Views
1K
Back
Top