- 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
I can't believe that people are defending the original code. It is completely atrocious. Duplication of substantially the same code with minor variations is always a bad smell. One reason is maintainability - if something needs to be changed it has to be done in mulitple places rather than one. The other is readability. There is so much noise there that it is difficult to see what the differences is between the cases. That not only makes it more likely that errors will be made but it also hides the intent of the code which is much clearer in the rewritten version.
And BTW are you serious about cutting an pasting being good practice?
Admin
Now if they were using Agile, it would be perfectly acceptable to write that code as it appeared originally, so long as it was eventually, and iteratively, refactored to Derek's solution.
Admin
I didn't even know you could do that! But uh... I wouldn't. Anyone who uses this kind of structure is setting the project up for maintenance hell. TRWTF is any language that lets it be legal.
Oh, and the the other TRWTF is languages that need special operators to tell the difference between assignment and comparison. Don't forget the "===" operator...
Admin
Sorry, try again. We've all dumped shit code into a project to get it out the door, but it isn't ever acceptable.
Admin
YHBT. YHL. HAND.
Admin
Admin
TRRRWTF is that this thing has five buttons numbered 4, 9, 11, 7, and 5, in that order. Seriously?
The other RWTF is that these index numbers are hard-coded into variable names, rather than being enumerated constants used as indexes into an array or similar kind of collection. Magic numbers are bad, mmmkay, but magic numbers hard-coded into variable names are worse.
Admin
"Image4.Visible := t = 1;" is perfectly clear once you're familiar with Boolean values and get used to treating them as first-class values. I.e., don't think of it as a case-distinction (even if the generated code may contain one, but that's the compiler's job, not yours), but think of it as a simple assignment: The visibility of the image (a Boolean value) is simply the condition "t = 1".
Admin
I'd be happy to. If you include the full text of the procedure you should notice something.
There's an "if" statement. Does pretty much the same thing in every language I know. Not sure why he used "<>" every time or why he's comparing with a boolean, but that might just be a nuance of the language. Or something.Admin
Admin
The first draft of pretty much any code is shit. Agile just accepts that as a reality, and allows for making it better at an appropriate time. Otherwise, you're just fooling yourself.
Admin
Admin
Admin
Admin
Sadly, I find my self agreeing with someone identifying them self as Nagesh. Perhaps it's time to rethink my life. HOWEVER, the advantage that using the '?' operator does is it saves a bunch of space in your source file. The disadvantage being it makes the intentions of the statement cryptic. Kind of like the classic strcpy trick in C
Perfectly valid... efficient... and it is important to understand how and WHY it works. However, so does:
If you are wanting to a dick measuring contest by having the smallest most compact source code - great. But if you want to make it understandable to the next guy who's going to have to maintain it long after you are gone, don't be a dick. (full disclosure: I used to be one of those dicks)
We're not working on PDP-11's any more. Memory and processor time is cheep. People's time is not. Chances are the processor is going to optimise:
the same way as the original example, any way.
Admin
Admin
No the code was not just refactored but i am sure Derek would not go on copy n pasting the 280 lines everywhere but rather put it in a library n use it. The WTF is after more than 10 years of experience they preferred pasting 280 lines of code. or may be the WTF is it took Derek just 7 years to know what he was doing not up to the standards :)
Admin
You seem to contridict yourself here. in VB you don't need an additional operator for assignment or comparison. The context of the "=" is what determines its function.
In VB x=y=z the first = is always an assignment all following = are comparisons. this si always true. THe problem comes when there is an implied assignment, as in "If x=y Then" there is an implied assigment to a boolean resulting from the listed comparison of "x=y". This is where the confusion between assignment and comparison happens. But the rule stays the same, the first implied or literal "=" is always assignment, all other "=" is comparison when looking at a line in VB.
Admin
Pascal? More like Delphi! Ah, great days - GREAT days! Back when men was men and women was women! Back when you could just go to the airport, WALK OUT RIGHT ON THE CONCOURSE with all the crew and the passengers and everyone, and you could meet people AS THEY GOT OFF THE PLANE! Back when you could drive to Canada JUST FOR THE HELL OF IT without a passport 'r nothin'! Back when, by God, you gave a man a rock and a club and pretty soon you'd be having yerself a wooly mammoth barbecue! Tough? Well, 'course it were tough - them beasts were migratory, y'know, but we had the teef fer it, back when!!! Not like the teef you get these days, no sirree, can't even chew a marshmallow with the teef you get today...<<mumble-mumble-mumble>>
Admin
Are you a moron? I thought anyone could see from a million miles across that it was a sarcastic comment.
Admin
That's actually an excellent solution, and might do the trick. 2 things to remember, though:
Admin
I can't believe there is one more moron who knows enough to write a huge paragraph, but cannot comprehend obvious sarcasm.
Admin
[quote user="Roby McAndrewI can't believe there is one more moron who knows enough to write a huge paragraph, but cannot comprehend obvious sarcasm. [/quote]
I can certainly believe there is one more moron who has yet to learn that sarcasm isn't an automatic feature of the written word simply because they intended it to be. There are idiots who espouse things like copy & paste coding and even worse. So we're supposed you're not one of them, how exactly? Because of your genius wit? That is amusing...or wait, was THAT sarcasm? <--- That is sarcasm.
Admin
Incorrect. You don't seem to under
Agile is not meant to "make shitty code acceptable", it's meant to "make a project better over time". Making a project better over time ENTAILS making the code better over time, but doesn't mean it's ok to write shitty code that will slow the rate at which you can make the project better over time.
You don't get better code by allowing shitty developers to write shitty code for someone else to fix (or break further) later. The point of going agile is to know that you don't have to have perfectly flawless code with all of the bells and whistles the first time, and spend 6 months building it just for the requirements to change 4 weeks in.
Admin
French is rubbish because they say "oui" rather than "yes". German is not quite as rubbish because they say "yah" rather than "yes" which is nearly "yes" so it's not quite as rubbish. Russian is really rubbish because they say "dah" rather than "yes". Spanish is quite rubbish because they say "see" when they mean "yes". American is really rubbish because they say "yo", "yep", "yeah", "yup" and all sorts of other silly things when they mean "yes".
See that paragraph above I just wrote? That's you stupid fucking programmers arguing about which of your stupid fucking programming languages is the best. Fuck off and sweep streets the fucking lot of you cunts.
Admin
What you do to make it readable is package it up into a function "max (a, b)" and then you only have to write it once. Then it can be as longwindedly-written as you like - or leave it as it is and comment it.
As for the "strcpy trick": fail. Put it in a function with a meaningful name, pricklips.
Admin
I got an answer: "How about NO?"
"x = (a > b) ? a : b; is legal, it's clear, it's concise, it's standard, it's well established...and if you didn't learn it by your third day of studying C, you are a shitty excuse for a C programmer, so STFU before I kick you in the nuts!"
Admin
Wow, both versions are a bit hideous. The second, while more compact isn't betterer because it fires every single time the mouse moves over the form, which should cause performance issues. I haven't used Pascal since a course in junior high in the 80s which is where code like this should've stayed. I just checked and yes Delphi actually does have classes.
//TODO: Give Image1...100 meaningfuller names like Button1Off, Button1On, Picture1, etc. //TODO: Store view elements in arrays and assign mouse event handling logic in a for loop. //TODO: Perhaps create a generic button class that internally handles on/off/selected logic.
Pseudo code (I don't know Delphi, but you should get the idea...):
Admin
I would suggest that you are deluding yourself if you think the first cut of your code in a small sprint is good. It is perfectly OK to just get something out there that meets the stakeholders' needs. That's why we have refactoring. As long as your system is sufficiently orthogonal, making improvements in the shitty parts are easy.
Admin
On a side note, I doubt that ":=" was used much before computers (or at least before type writers). Why compound two symtols when you can just as easily draw a new one? (Such as "≡", which is also used for definition.) I don't really know the history, though.
Admin
y = 12x evaluate for x = 3.
Admin
Anyway, I prefer Python's version:
It's a little easier to figure out if you've never seen it before.
Admin
One detail about C#'s conditional operator is that it is an expression, not a statement.
In C++ you might see
someFlag ? Foo() : Bar();
but that code would not compile in C#.
Admin
Apparently he didn't learn the "if it ain't broke, don't fix it" lesson.
Admin
It took that long to figure out how to edit in a real WTF.
Admin
Fixed that for you. Problem?
Admin
Like and +1.
Admin
Admin
Looks like another great reason to stay away from Python.
Admin
I can't see both sides. Yes, it is that ugly, and it will be expensive to maintain: hours instead of minutes. If someone asked me to modify it, I would do the same as the poster, and I have much more than ten years of experience.
Eventually the cost of maintaining a pile of WTF puts companies out of business. Then the cut-and-paster gets laid off and never works as a programmer again.
Admin
Admin
Well, yes. I hope I never have to deal with a language where (a = b) is different from (a = b).
Admin
It's perfectly clear to me; I hate using an if statement to test the value of a boolean and then return that very same value.
Admin
Admin
Surely the subjunctive would be "I wish the last statement were true". "Would be true" is, as far as I can see with my limited knowledge of grammar, indeed ungrammatical.
Admin
Pretty sure this is Ada code.
Admin
Wait a minute, i'm noticing a pattern here. Does every comment with the word "Alex" in it get made a featured comment :)
Admin
hmmm...sounds like assignment to me...
Admin
This is why I run screaming from liberals, Catholics, and Agile developers. Some of each category are just fine, even awesome, but the common example hasn't got a clue how fucked up their bad interpretation of the given paradigm is. If that isn't bad enough, they will defend their position to the death.
Admin
That's a very strange way to implement a Semafor.
/YoureDoingItWrong