tags:

views:

1077

answers:

44

What is the thing that irritates you while doing maintenance coding?

Can you point out some points for easier maintenance for me and my fellow programmers?

+4  A: 
Paul Sasik
That happens often.
JMSA
+17  A: 

That I cannot resist refactoring it. Even though it's my own.

And that after refactoring, the original idea seems clearer, and not so bad at all...

xtofl
+26  A: 

That it's my own code that I have to maintainence on, so I can't blame someone else when it's not working...

Guffa
And the worst thing is, while searching for someone to blame for, I suddenly discover that the culprit was myself. Then I just hide the thing in a corner and say that, "No. Nothing actually happened".
JMSA
Worse when you've already started cursing loudly in the office prior to realising it was your own...
Paddy
lol. Totally agree. And this is what makes one a better developer... making him/her go back and see what he/she did and how bad it is. lol.
Paul Sasik
+14  A: 

A WTF-per-line ratio greater than 1. :-)

Christian Hayter
Nice one. So what's your threshold of WTFs per method, class? ;-)
Paul Sasik
Hey what does it mean by WTF? :-D
JMSA
@JMSA See http://www.thedailywtf.com/
Mark Pim
I could have voted ten times for this. So niceeeee
Suraj Chandran
My personal threshold is more like 0.1, but one has to be practical about these things and fix the most glaring WTFs first. :-(
Christian Hayter
@JMSA I believe it's referring to one of XKCD strip that the only valid code quality measurement is by WTF per minute. The wtf in thedailywtf however stands for worse than failure, which is different...
SyaZ
SyaZ: AFAIK, it no longer stands for "worse than failure". Alex finally gave into the pressure and brought back the original name after a series of unpopular name changes.
rmeador
This is a rare instance where xkcd was NOT the creator of this phrase - it's from http://www.osnews.com/story/19266/WTFs_m
DisgruntledGoat
Also... you're happy to accept one WTF on EVERY LINE?
DisgruntledGoat
@DisgruntledGoat: There *is* a smiley at the end of my answer...
Christian Hayter
+7  A: 

The fact that such code is usually riddled with many bugfixes. Uncommented bugfixes, so you have no idea why the hell the previous programmer returns from function x when y equals '5'.

Razzie
+3  A: 

When the only design documents are the codes themselves, written by someone I don't know or can't get access to. And the codes have no comment.

Making it worse will be a lot of redundant (if I know at all) files/codes/DB tables/columns which confuse me further, not to mention time wasting.

o.k.w
This has got to be the worst thing about working at an internal IT department.
Mike Burton
A: 

single letter variable names! (This does exist, today) Ackkk

prochaine
But it is not uncommon while writing for/while statements.
JMSA
I feel that they are still ok, but only if they have a very small scope. Like i for loop counter, or parameters in a lambda expression.
Guffa
And lambdas (.........................)
UpTheCreek
So thumbs down for the answer of Unknown.
JMSA
+6  A: 

That the unit tests don't exist, and the code hasn't been architected to facilitate unit testing. So I'm faced with code that doesn't have defined behaviour (via unit tests). I then have to change the code to be testable, and that in itself could change the behaviour and remain undetected....

Brian Agnew
+2  A: 

When the code doesn't make best use of the language. Use the language the way it was intended.

Concentrate your maintenance on clarity and correctness: Use smart pointers here, make this a class. Catch that exception and clean up before rethrowing. Don't go crazy making huge architectural changes unless the existing architecture is causing the problem, or preventing you from fixing actual bugs.

Matt Joiner
+14  A: 

That my child, who was so beautiful when she was born, has turned into an ugly brat who won't stop talking back nor do what she's told. Not content with that, she makes a point of embarrassing me in front of all my friends.

As for a suggestion: unit tests -- at least that way you can remember (or figure out) what she was taught as a child and make sure you don't break it (unless that's the point).

tvanfosson
+4  A: 

That everyone else is a complete moron, totally screwed up the design, created an unmaintainable mess of spaghetti code, commented the easiest stuff and forgot to comment on the hard-to-understand stuff.

The most irritating thing is that, much too often, it's a former me that was the moron.

I guess I just don't like digging through stale code.

sbi
+2  A: 

When the code I am maintaining is written badly, without oops, using wrong or messy architecture, because then I have to either change a lot of things or act as wrongly as the previous coder did.

Krishna Kant Sharma
Yes that happens a lot.
JMSA
+2  A: 

Can you point out some points for easier maintenance for me and my fellow programmers?

One word: Refactoring.

Ewan Todd
+4  A: 

Worse than uncommented bug fixes is comments that are out of date or just plain wrong.

Kenny Drobnack
+5  A: 

When I realize the code I am debugging is not even working. It was simply not tested enough. And I am wondering how come this code was checked-in. How come someone else could have think it was working.

decasteljau
+5  A: 
#ifdef BAD_CODE
... stuff that has been useless since ages
#endif

a couple of useful lines

#ifdef BAD_CODE2
... more stuff that has been useless since ages
#endif

And so on, ad nauseam. This construct can be handy to test your hypothesis, but these bad blocks have to be removed asap.

fvu
I shouldn't say this but wow, what an awesome neat trick! Much quicker than un/commenting all the time, just change one value. But you're right, delete as soon as you're done.
DisgruntledGoat
+4  A: 

When you have large sections of commented-out code without any explanation of why those sections have been commented-out. Usually this is just a lazy alternative to version control, but sometimes it may indicate a temporary fix that the developer is unsure of, or some other condition you are not aware of.

So do you leave it? Delete it? Make a back-up and delete it?

Dan Diplo
I always leave it. Coz why risk myself for some other's wrong doing. How can I be sure that I won't be accused for deleting this comments one day?
JMSA
I always delete it. If I feel really unsure, I'll replace it with a (short) comment to that effect. That's why we have version control, after all. And commented-out code greatly hinders readability, and after a few unrelated changes, is unlikely to be useful anyway.
sleske
typically, I leave 'deleted' code in there commented out, so if I have to go back to the code for a bugfix, I can easily see if I've made a huge cock-up by looking at what the old code was there to do. After the first time though, I delete any commented out code blocks
gbjbaanb
Just delete it. There's enough cruft as it is. Be a part of the solution, not a part of the problem.
JimN
+3  A: 
  • Unclear variable names e.g. m_strObjArr
  • .NET code littered with Hungarian Notation, especially when applied inconsistently e.g. m_strI, strI, objArr (Microsoft recommends not using Hungarian for .NET naming: http://msdn.microsoft.com/en-us/library/ms229045.aspx)
  • If-then blocks without braces
  • Duplicated code. This is especially irritating when the same JavaScript or C# method is pasted on every page in a site instead of it having been factored into a common file.
  • No instructions on how to get the code running on a local development machine or deploy it to production.
Mike Knowles
But Hungarian notation is a part and parcel of MFC and Win32 programming. How can I possible get rid of those?
JMSA
I should have specified .NET-based code - post updated. Microsoft's standard recommendations for naming in .NET programming is to no longer use Hungarian notation (essentially starting with .NET they adopted the Java style of naming): http://msdn.microsoft.com/en-us/library/ms229045.aspx
Mike Knowles
+58  A: 

The thing that irritates me the most while doing maintenance coding? Easy.

That management thinks that any fix can be done as easily as flipping a light switch. That any fix occurs in a vacuum, that it won't have any side-effects, that it all works like magic.

And that no amount of logical, rational explanation will convince them otherwise.

Mike Hofer
Oh great answer. I would have voted twice if I could.
JMSA
While I understand the feeling, as I'm getting older I'm starting to see that when someone is looking for a band-aid, it is usually ok to give them a band-aid. Also, that having trouble communicating the challenges involved in a feature or functionality change is often a problem on both sides of the table.
Mike Burton
+2  A: 

Coming across bugs caused by someone copy-pasting a chunk of code and then not actually modifying it to get the correct behaviour in the new place (let along the fact that they copy-pasted in the first place).

That's my current one anyway, having come across it most recently while doing maintenance coding :)

workmad3
+7  A: 

Comments written in a language other than English.

Greg Hewgill
What the hell is this? I never encountered such a thing yet.
JMSA
Years back, we hired some Russian devs. When it was time to get rid of them and bring the maintenance of their product in-house... we found *all* the comments were in Russian. We had to keep them on as no-one else could understand what it was doing... good job they were cheap! :)
gbjbaanb
The project I'm working on now has some (not many) comments in French. I can usually read them, but I have to translate for my cow-orkers..
Greg Hewgill
Ja, visst är det irriterande. ;)
Guffa
If you think Hungarian Notation is bad, try to understand a piece of spaghetti mess that extensively commented - in a mix of English, German, and Hungarian.
sbi
+4  A: 
  • See copy-pasted code from experts-exchange.
  • See your own code broken by another guy.
  • Find awfully written unit-tests.
  • Don't find them
Matias
Yeah, nicely arranged points.
JMSA
+1 for #2. that pisses me off more than you can imagine. I've shouted at coworkers for it...
rmeador
I shuddered at "experts-exchange".
DisgruntledGoat
+6  A: 

Code duplication.

I've seen code where entire methods (even classes), had been copied, and then parts changed. Sometimes you had classes of >1000 lines, with 80% of the code identical. Just hunting down all the places to change something can be a nightmare.

The first thing I do is usually try to refactor this (which is not always easy).

And yes, I sometimes find it was my own code (though I hope I'll never do it like this again).

sleske
Seen this many times myself. Once I found someone has copy-pasted a block of database connection code dozens of times throughout the app - including a commented line and an unused variable declaration!!
DisgruntledGoat
+1  A: 

Uncommented code, compact statements (e.g. single line ifs etc) and inconsistent variable naming.

Oh and I'm a real stickler for nicely laid out classes, keeping properties, methods, constructors and private variables grouped together.

fat_tony
A: 
  1. Discovering that the existing code is written in PERL
  2. On examining the PERL code, discovering algorithms like the following:

Suck whole file into memory, substitute all newlines with some char, record the substitution count, open the same file again, start a for loop from 1 to the count of substitutions, read a line, do something.

I kid you not!

Michael Dillon
+1  A: 

What is the thing that irritates you while doing maintenance coding?

I am more often than not annoyed that I am working on code which I had been done with for some number of months, if not years. It's not so much the coding that bothers me, it's just that I mentally check out on certain projects after a given amount of time as I move on to future projects. Older projects become less interesting, yesterdays news so to speak.

Also, as time passes, I tend to forget the workflow of the code I was previously working on. Concise comments are a real time saver for cases like these.

This is particular to web development in my case, but I know it carries over to all branches of development.

cballou
Bravo ................
JMSA
+2  A: 

hard-to-read code:

  • wrong indentation
  • inconsistent coding rules or no coding rules at all
  • useless comments (I prefer no comment)
  • out-of-date paper documentation
mouviciel
+1  A: 

Unexpected non-local scope of the code, i.e. you change something in one part and in some almost incomprehensible ways, something else in a completely different part of the system suddenly fails. Drives me mad.

ammoQ
+1  A: 

You are fixing the most critical bugs in the most critical system, and your peeky research collegue says: "Oh you are still maintaing code. That's so kid stuff"

Suraj Chandran
+2  A: 

Giving a workload estimate for discovering and fixing a tough bug when initial information is the issue report stating "The software doesn't work". Usually my answer is: "between two hours and fifteen days"

Then justifying why I spent two weeks for adding only a couple of characters here and swapping two lines there.

mouviciel
one of my coworkers once worked to debug an issue for weeks, then had to actually fly to the customer's site (since it wasn't reproducible locally), then found that there was a single missing quotation mark that somehow got removed from their copy of the script. 1 character change, untold thousands of dollars and tens of hours consumed.
rmeador
+6  A: 

Very easy. Swallowed exceptions. e.g. (c#):

try
{
   //Do something
}
catch
{

}

//Keep doing something else.

This leads to all kinds of fun bug hunting, usually based on a bug report that you can't recreate. My motto to all juniors is now to never (ever) swallow an exception without logging it.

(Close second is badly written code within a transaction, where an error causes the transaction to hang, and the only error message you get is about a locked DB, with no explanation of what caused the original error).

Paddy
A: 

Lack of unit tests to go with the code. I can live with no-comments, useless-comments, less documentation etc. But no unit tests, that a hell.

sbidwai
A: 

Dealing with code written by six different people who all thought they had the right way of doing things and should do nothing to respect the patterns of those before them, even at the most basic level.

Ever tried to read code that is camel case or pascal case or hungarian, and that changes within any given class or function, with three different comment styles? Sprinkle that with a few derisive, note-to-self comments ala "this xyz prior person was wrong but I don't have time to fix this..."

Russell Steen
If you do Java, take a look at Jalopy, it does code autoformatting, and may be able to fix capitalization/case issues as well.
Dean J
A: 

Public interfaces with methods like:

DoFoo1()
DoFoo2()
DoFoo3()

Remember people, if you make it public and release it - you have to support it forever!

Another one is to find a nice long comment that someone has clearly taken the time to write - but the code it was originally next to has either changed behaviour, moved or been deleted.

Philip Wallace
A: 

Nothing. I love coding. I love maintenance coding. The sooner you all come to peace with, and find passion for your jobs, then you'll see that things like petty irritations are a fabrication of your own minds, and have pretty much nothing to do with the code in front of you, or how "unbelievably bad" it is, etc.

Alex Baranosky
Hey, I love my wife with passion - but I can't that say my marriage is irritation free! ;)
Philip Wallace
Then I'm sure you will admit that the "problem" isn't really in your wife, but in you :)
Alex Baranosky
+5  A: 
  • duplicated code
  • bad identation
  • unclear variable names
  • magic numbers
  • magic string constants
  • very long methods
  • unclear naming of methods
  • out of date documentation
  • inconsistent coding rules
  • lack of revision and authors tags
  • lack of documentation
  • no OOP at all
  • copy & paste
  • anemic classes
JuanZe
I was going to list the opposite of anemic classes; thousands-of-lines long classes that fit better into a monster movie than a professional solution.
Dean J
+1 @Dean I also agree with that. I wrote "very long methods" thinking about those huge classes with a lot of end-less methods.
JuanZe
+2  A: 

My biggest pet peeve: code rot.

In other words: we start out with a pristine, beautiful application. Over time, new features are added to it -- of course, whoever is working on the changes just slaps their code anywhere. Another person works on the code, can't figure out what its doing, and just wedges their new fix or feature wherever it fits. Fast-forward a year or so later, your once shiny and polished code has turned to rust. Its barely held together with duct tape and rubber bands.

So, what happens next? Management wants a shiny new feature added, but you can't work it in without architecture or database schemas having an impact on existing code. You've got deadlines to hit, so what do you do? Write a hack that sort of works, wedge it in wherever it fits, and hope you have time to fix it later... [cue the Lion King's "Circle of Life"]

Juliet
I try to keep in mind that the goal of development isn't "the perfect application backend", but "happy customers". No amount of perfect code pays the bills; one happy customer might fill that niche, though.
Dean J
+1  A: 

People who think you can get that critcial show-stopper bug fixed faster if the call you every five minutes.

HLGEM
+1  A: 

Currently, multiple rounds of undocumented shortcuts and cut and pasting code resulting in incorrect comments, method names, and variable names, so that it requires a code anthropologist to pick through and figure out what it is doing, what it should be doing, and what the original dev might have intended it to do.

Dean J
A: 

When not one developer in the company wants to own up to the current functionality of the code...

Egg
+1  A: 

The book Clean Code by Robert C. Martin contains a lot of example of how to make code easier to maintain.

Kristoffer Kjeldby
+1  A: 

One thing that can wear on you very quickly is inconsistent formatting. Even though most modern IDEs will do fairly well in keeping it in a neat format (well maybe not IDLE :) ) people will still find a way to make their nests look like sylvester the cat just got done with them.

That can also be a piece of advice to help make maintenance easier, develop and enforce a department code formatting spec....depending on what you are working in, there are some built in "code style" formatters (IntelliJ IDEA) and tons of third party ones(Visual Studio).

That way when the coder is banging out code, it could look like all hell, but after unit tests and they go to commit to the source repository, they just pass it through your groups' formatter, and its nice and tidy when it's committed.

curtisk
+3  A: 

Uncommented code.

Yeah, we get it, you think you're God's gift to programming and that your coding is "self explanatory". I don't care. Comment your damn code regardless. You have NO IDEA what type of programmer is going be coming in after you; it could be someone fresh out of school that isn't aware of the techniques you use.

temp2290
A: 

Developers who take offense to the fact that you changed "their code" and that there is nothing wrong with it. The problem is always "somewhere else" in "someone else's" code. So I guess it would be developers who presume he or she is infallible.

joseph.ferris