- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Interesting thing here is that you gained insight in the code and presumably commented it so the next guy won't have to do the legwork. You still gained from this, and it sounds like this code would be a candidate for refactoring if you end up having to make significant changes there.
Admin
I can't sell the Phbs on a software upgrade that will pay for itself in 3 years, and show a solid profit for 7 more.
You act like this is merely a choice made by lazy programmers who don't want to start from scratch, but starting from scratch is costly and in a situation where it is either dedicate thousands of man hours to rewriting the application from scratch or accepting that every modification will take 2 or 3 times as long, the phb is going to pick the latter option every time, even if, even if the man hours lost to modifications will outstrip the time needed to do a rewrite in a few budget cycles.
You have to understand that no boss wants to take on the headache of a new system, with all of its inevitable bugs, without a good reason. And when the reason is something like "its hard to modify" you will not get permission to do the rewrite.
Admin
A doctor of philosophy is Ph.D., not PH.D. Maybe he was being sarcastic, like "Wile E. Coyote, Super Genius".
Most Ph.D.'s I know (in science and engineering) spent five years in near poverty living on stipends rather than earning 3 to 5 times as much in industry. The reasons to do so include love of learning, procrastination, more time to party like a college student, and avoiding crappy entry-level jobs.
Admin
Read what I wrote again: I'm not calling anyone out, nor am I suggesting you start from zero. I'm saying that this is how you can make the code better. All you need is a plan for the architecture that people buy into and the will to refactor towards that goal as part of your normal maintenance.
It's hard to modify means more bugs and longer feature changes, so sell them on that. Pay me now or pay me later.
Admin
I think the problem is that it's very hard to impress on your average PHB (even if you're lucky enough to have a boss who was once a programmer!) how hard it is to maintain lousy code. You can bitch till you're blue in the face about how fragile the legacy application is, and how any change will bring the house of cards crashing down around your head, but 9 times out of 10 they won't believe you until it actually happens. It's hard for them to estimate the liability imposed by working-but-crappy software, so they just don't.
Admin
(1) Depreciation/Amortization. Built in. Roughly three to four years, depending upon accounting. Try harder. (2) No obvious reason to start from scratch. Try harder. (3) Try to explain to your boss how he/she will have less headaches. Try harder.
(4) Do your best not to be a total wuss.
I don't have high hopes on any of those, but, y'know? I told you so.
Admin
Oh, and during the kerfluffle, you could let top-level investors know there was no backup system protecting their investment.
... might want to have your resume (or a job offer!) in hand before pulling the trigger on either of these, though.
Admin
What is this? I can't debug this. There's no code here!
FREAKING THING SUCKS! **** IT! WE'LL DO IT LIVE!
Admin
Rocky: "It looks like we're in real trouble this time." Bulwinkle: "Good, I hate that make-believe kind."
Admin
If it's not maintainable, it's broken. The way to fix that is not in one big gulp, but in lots of little needle pricks. Each time you come across a thing that is backwards, make that particular instance not backwards. Re-factor a single global variable in a day. Keep up the bill-paying work velocity, and make sure you make non-zero forward progress on re-factoring over time, and over time, the application will suck less.
Admin
OK, this is C# code. It's a handler for a controls TextChanged event. It looks like it was generated by a wizard (i.e. the 'normal' way of developing in C#). Somewhere will be a line of code which is referencing txt_fld_TextChanged, it probably looks like this
some_ctrl.TextChanged += new EventHandler(txt_fld_TextChanged); (or similar, sorry don't have my C# hat on right now)
Aside from the fact the the control is probably named 'txt_fld', if the idiot managed to hook up a delegate to its text changed event, surely he can track down where the other references to the object are.
I guess the WTF here is that the comments are the WTF instead of the code, but it's hard to tell from the article.
Admin
How about an analogy? I live in an old house. It's drafty, the wiring is sub-standard, the septic tank won't meet current codes (but is ok because it's grandfathered), it has termite damage, the front porch is falling apart, nothing is square, plumb or level, it needs to be painted, the basement windows are a disaster and it's poorly insulated. In short, you can make a valid argument that my house "sucks." But I doubt any of you in my situation would tear down the whole building and rebuild from the ground up just so you can install air conditioning.
Admin
Especially compared to adding hundreds of lines of "why this code sucks" comments like the developers in TFA did. Talk about contributing to the problem!
Admin
No need to keep it in your pants if you wipe when you are done...
Admin
Admin
Well, only one line of that comment is rude. I usually comment the code in detail, so that the next person who will read it, will know what it is meant to do. It happenned several times that some "smart" programmers have deleted part of the code, just because they did not understand it or thaught that they could do better, then asked for help.
Admin
It's one thing if there are unit tests that'll validate that your changes don't bring things crashing down, but this sounds like one of those legacy applications that really does fit the 'if it ain't broke, don't fix it' mantra.
I don't know about you, but I've worked on systems where it seemed that if you even looked at code in one part some other seemingly completely unrelated area would break. For those systems, you don't change things unless there's a specific requirement (bug fix or a planned rewrite). It's not a wonderful situation, but it is what it is.
Admin
http://wiki.debian.org/SSLkeys#head-76415d1c2f25f12ebbcc99bb93959a97f18e3b88
Admin
If there is one truth in software, it is that all software sucks. I'm yet to hear a single developer who thinks the stuff they work on rocks...
The only exception to this is Windows XP which sucked until Windows Vista was released, it was then considered to be a solid OS.
Admin
I can see it now, aging is cured you have a several trillion dollars (thanks to inflation) and are about to get on your space plane and finally retire to the beaches of Antartica, when you get arrested and tortured. It turns out the date bug you left in the system that is now tightly integrated into the CIA (complete information awareness) system and causes your name to popup next on the "citizens are terrorists" interrogation list.
Admin
It is a type of TARDIS.
Admin
Admin
Most code I've seen sucked. In many cases it didn't suck as hard as I thought at first, but on closer inspection it sucked almost without exception. Otherwise there is no point in paying a developer to work on it is there?
Mind you I have seen some code that didn't suck, but usually I stop looking there and just use it.
Option b is a really common an viable reason to be changing somebody elses code imho.
Admin
When you are dealing with Moldy Swiss Cheese code, you may not have time to chase down all the interlocking bugs, fixes, tweaks, workarounds, and general overall kludges -- since fixing one can cause cascade errors to other code which was written to "fix" a problem which your fixes have now eliminated -- and thus triggers said "fixes" to crash the program.
At certain points, the fix process is as time consuming as a full re-write, which your own job requirements and/or management may not allow for.
"Hey, it's working, leave it alone" is often the only perception of point-haired management types. That it's a house of cards disaster waiting to happen is something they choose to remain vigorously ignorant of.
Admin
Great idea, I have the joy of being responsible for maintaining a nice old C monster. I would really like to see how you upgrade it into something that doesn't invoke nightmares.
I'm sure you could remove a global variable in just under 3 hours. (Hm, makes me wonder if there are any limits to the number of variables you can pass to a function)
The problem is that the whole program was designed with bug oriented programming in mind. (or at least that is the only explanation I can think of for some of its "features")
Admin
Hmmmm.
Maybe I'm a masochist but I frankly enjoy stuff like this. You come into a tough situation, find a shitty application or system and then rework it into something nice, clean and elegant.
Much more satisfying IMO than creating something from scratch because it's much more challenging.
Then again I also enjoyed programming in RPG and assembler so the masochism theory is still in play. :)
Admin
Yeah it does make you feel pretty damn old doesn't it?
Admin
Prime candidate for renting out!
1/2 off first month's rent!
Admin
http://en.wikipedia.org/wiki/Wayback_machine
Admin
You need to have less imagination.
And caffeine.
Admin
Indeed. We have been in the same situation really. It started when around 2001 a downright IDIOT wrote a piece of code. This person had very little programming experience and no formal education in CS or anything like that. The business started slowly, but eventually it started making money. There always were problems with that particular piece of code. Sometimes it would crash completely, at other times it would hang and in between it sometimes would just not registrate something when it was supposed to do so.
During the years, fix upon fix was applied to the code, making it such a monstrosity that nobody knew what the code exactly was doing. There were tons of methods with totally incomprehensible names, with in them loops nested to 10 levels deep. When looking closer at the code, these loops stated to look suspiciously familiar after a while and it turned out the same 100 line nested loop mayhem had been copy/pasted a few dozen of times with only some slight changes every time.
To make matters worse, approximately 70% of all code simply did nothing. It were just leftovers from copy paste actions. To call any give method on a class, you first had to assign a couple of values using public instance variables of the class, a couple through getters and then also pass a couple directly to the method. And if you think this was bad, consider the fact that the original programmer did not know the programming language had something like types and made everything a String. Also, this programmer had the insidious habit of giving random names to his variables. A customer ID would be called "rabbitID" at one location and "proofOfIntendID" at another. To really finish the job, a variable called customerID would often actually hold the product ID, but not always...
And in case anyone even thinks I'm making any of this up; the actual situation was even worse than this!
In some magical way however, after a few years the code worked. For about 95% of the cases...
Recently this idiot programmer announced that he would be leaving the company. This is probably a good thing for the company, but the problem is that this abomination of code that he created runs at the core of our business process. At some point of time it undoubtedly needs to be fixed again. It also undoubtedly needs to be extended with new features as it really is the kind of code that needs to accommodate an ever changing market.
Since no programmer in our company, from the highest ranking "I know everything" senior to the lowest ranking "I'll do anything" junior wants to touch the code, there simply is no way around to rewriting it.
Yes it works now (in a way) and yes it's critical to our business. But if we don't start rewriting it -now- we might run into some very serious issues even a few months from now...
Admin
http://www.justfuckinggoogleit.com/
Admin
I used to toil through code like that with testing software. We used a massive script system that manipulated Windows GUIs, and the scripts were full of comments like that:
Here we have to grab not only the main window, but scan to see
Which is the Okay button. Sometimes it's a graphic, sometimes
an actual button. What fun it must be to work for this company's
UI!
and some were mean:
You may not know why this subroutine exists, but it's called
everywhere for a reason. Wanna know why? Because some WINDOWS
FUCKTARD who doesn't ASCII from ANSI, who were shitting their
diapers when modems still did 300 buad, and so they think that
ANY character over 127? Doesn't exist. Poof! International
letters? Please! Speak American! I hate them. And so when
"weird squigglies" started appearing in his forms, well, nuts to
that! Turn them all into "space." But he made this transparent
so a lot of the text generated looks like a space, but might
be 0xB4, and NOT 0x32, so scanning for "words" is fucked up
because of all these non-standard "spaces" that aren't.
I knew the guy who wrote those comments, and I actually liked him.
Admin
[quote user="Query Object: G.E.D"][quote user="Steven G. Aldana, PH.D."][quote user="snoofle"][quote user="Steven G. Aldana, PH.D."] snip P.S. If you really need to flaunt your degree, you're overcompensating...[/quote] I didn't realize my huge degree was so intimidating. From now on I will try to keep it in my pants.[/quote]
In behalf of all users, we is thankful in your help.
[/quote]
Allyou're titlez are belong to us.
Admin
This site suckx
Admin
I'm a bit alarmed by the relativism expressed in this discussion.
There sure is sucky code "out there". Code that works just because of chance and luck. Code that is unreadable. Code that was written by someone who really didn't understand the programming language, the used libraries or even programming in general.
Sure, you can take 'oh, this is a horrible kludge'-type comments too far, but really, they have value.
The thing to look out for is a developer who thinks ALL projects except his own suck. That person probably is just bad at reading other peoples code.
But a person who comments, say, 10% of code he maintains in that way is not someone I would be suspicious of at all. Heck, in some corporations I think >50% of the code would benefit from warning-comments....
I sure am glad to work on a non-WTF-company at the moment though...
Admin
No, it isn't always an option to rewrite a decade's worth of code, but it should be. No matter what the other business priorities are, if you have code that is horribly written and difficult to debug, the amount of time and money spent on fixing problems with it is reduced drastically, not to mention the time spent training new people on the code or letting them work out how to debug it. If you don't have the time to do it, time should be made, because if it isn't it'll just get worse and worse, and it's only a matter of time before it blows up in your face. All it takes is one big problem that takes months to fix for it to be worth it.
Admin
Admin
The last place I worked, I left a large amount of comments similar to this. But mine were more along the lines
// The obvious solution to this problem would be to implement data locking in the table during processing.
// However, (Name omitted) has insisted the solution is to implement a duplicate table, store the changes in the duplicate and then check for conflict after. // (Name omitted) told me not to use the built in DB features and do it this way because that's the way they always used to do it.
And the reason I specifically put those in the code was because I knew later coders would be looking at my work and saying "Why the heck would you do something so stupid?" I wanted them to know I knew better and to also give them a heads up as to why they were done the way they were.
Admin
ROTFLMAO
Admin
The real WTF here is that they left DEBUG code in with PRODUCTION code. It isn't even Debug.Writeline() or anything. What is the point!
Admin
Lol reminds me where I used to work before where that senior developer kept complaining about our code but never tried to teach us anything. He should try and help ..and that is why he is a senior developer no ?
Admin
But like James, I'm working at a place where management does not see value in refactoring...
Admin
If the angry developer had spent as much time refactoring the code as they did writing that novel of comments, perhaps it wouldn't suck so much.
Admin
OK, so we have someone who doesn't know what is changing the text in a textbox, so they add a bunch of crap code for debugging purposes. THAT is a WTF. And, it isn't even in a conditional compile statement.
This is C# code, so one possibility is that the original developer used DataBinding to implement a coupling between the data and UI. Standard UI practice. In this case the person adding the comments is an idiot.
Or, there are calls to set the Text property explicitly, in which case it is possible to register an anonymous delegate in the immediate window of Visual Studio that performs a Thread.Sleep, allowing you to pause the execution in Visual Studio and view the stack trace without having to pollute your code with a bunch of crap.
Admin
At least there is some comments! haha.
Where I am right now, reading a few lines of code, you can come to the same conclusion...you dont have any comments to warn you or scare you. But for even general good practice of commenting your code, there's not of that here. You actually have to do some CSI (code snippet investigation) before you come to the conclusion..."This Application FREAKIN Sucks!"
Admin
Found this on a piece of interface code that has been failing for the last week:
'********************************************************************* '*** '*** NASA SAYETH: BETTER, FASTER, CHEAPER. PICK TWO. '*** (I.T. Translation: SOLID, EFFICIENT, RAPIDLY-DESIGNED. PICK 2). '*** '*** $CIO chose BETTER and CHEAPER (less develepment time). '*** '*** The end result is that this code is abysmally slow. '*** '*** Some areas needing re-write:
Followed by a list of a half-dozen places where refactoring would speed up the code.
Admin
Go for it - probably most of the money value is in the land anyway - that house needs to be burnt to the ground to rid the area of termites!
Admin
I once left pretty rude comments in a legacy app, too. It was some madness like "we want to know if a certain value is in a certain column in the database, so we query for the ENTIRE FRICKIN' TABLE and do a for loop OVER EVERY FRICKIN' ROW and if we found the value, we set a flag to 'true' but WE WILL CONTINUE TO LOOP THROUGH THE ENTIRE RESULT SET because we already got it from the DB, so we can at least look at it, right?"
Followed by some more madness where EVERY FRICKIN' ROW of a DataGridView got checked for value changes if you changed only one row. This is okay if you only have 3 or 4 rows, but with a few hundred rows it really slows down the whole application (worst thing: None of the users ever thought about complaining why the app is so damn slow, I found out about it by pure accident).
I left a rude message, scolding the old developer and replaced it with something more efficient. But a few days later when I looked at it again, I simply deleted the old code and the comments, just leaving explanatory comments of why I chose to do things the way I did them. I figured that a) it's never a good idea to have rude comments in your code; b) they wheren't very helpful and c) I didn't want to come accross as an arrogant "know-it-all". If I made mistakes in my code (and I'm pretty sure I left behind some VERY bad code) I'd appreciate if someone just explained to me why it was bad and how I can make it better in the future.
So yeah, I agree with what has been said: Comments like this should NOT be in any codebase.