Skip to content

The Weird and The Wonderful

It was the best of code, it was the worst of code. Coding Horrors, Worst Practices, and flashes of brilliance

This category can be followed from the open social web via the handle the-weird-and-the-wonderful@forum.codeproject.com

1.8k Topics 20.7k Posts
  • Whoa! Didn't see this one coming

    com
    18
    0 Votes
    18 Posts
    3 Views
    M
    It's a great way to detect that something isn't quite done yet. Cheers! "With sufficient thrust, pigs fly just fine." Ross Callon, The Twelve Networking Truths, RFC1925
  • Culture vulture

    com
    6
    0 Votes
    6 Posts
    0 Views
    L
    Rounding is a hard, let's go shopping! ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))
  • 0 Votes
    19 Posts
    0 Views
    B
    My assignment at the time was match up binders to loose leaf contents. It was easiest if manufacturing knew how many binders to make with the content already in them. So I had three result piles, binders only, content only, combined binder and content. Now do that in a single SQL statement. (That's not really a challenge, I'm sure someone could do it.) I was fresh off their two weeks of Oracle SQL training at the time. I knew it was going to be bad when I sat down at the conference table and the team lead turned to me and asked me why I was there. I was the programmer assigned to do this? OK, you can stay. So 50 minutes into the discussion of the project, the Oracle lead consultant (the one being billed at $300/hour instead of the minion $100/hour) pops in, gets a synopsis, and declares, "this shouldn't take more than two weeks," and leaves for the next meeting he is already late for. I spent the first week staring at the problem, going around to the supposed Oracle experts, telling them the objective, and hearing them say, "That's an interesting problem, I'll give it some thought." So in the end, I said, screw it, I'm going to do it the old COBOL card-in, card-out way. I created two cursors (this being the mid-90's and cursors were cool) selected the data and sorted on a common column, and walked the two lists comparing them, creating a new record for each of the three bins. In the meantime, my project partner, the one too busy to help with the programming, he was just there to "liaise" with the project principles, came by after two weeks asking where the output was. I said, "Did you hear me say it was going to take two weeks?" I had protested at the meeting, but the BIG BRAIN had spoken with his estimate and that was it. I handed it in a couple days later, but 80% Rob, as we called him (he would do only 80% of the work, declare victory and move on) threw me under the bus by handing in only two of the three files I gave him. This ended with a stakeholder in the project coming to my cubicle and telling me what a slipshod job I had done. Twenty minutes later of making an accidental enemy had me finally realizing what had happened. When confronted about this, 80% Rob said, "Somebody dropped the ball." Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.
  • Every day I die a little more...

    csharp javascript asp-net tools tutorial
    7
    0 Votes
    7 Posts
    0 Views
    K
    Yes, that would be a good approach, but they've agreed to a re-write (on the grounds our current site really doesn't play well will googlebots) but they want the new system to be as patchy as the first. Naturally, there is some politics going on which is behind all this. Sort of a cross between Lawrence of Arabia and Dilbert.[^] -Or- A Dead ringer for Kate Winslett[^]
  • Stupid of the day

    testing debugging beta-testing question
    7
    0 Votes
    7 Posts
    0 Views
    R
    :laugh: that's funny. That reminds me of the time my web page kept returning an error when I was trying to view a text file. That is until I realised, the file contained text of a web page error. It must have been a Monday.
  • Try Catch - at least it won't break

    asp-net
    4
    0 Votes
    4 Posts
    0 Views
    B
    Seeing far too much code like that is what made me choose my signature line. Just because the code works, it doesn't mean that it is good code.
  • YAVBH

    oracle help career
    5
    0 Votes
    5 Posts
    0 Views
    R
    Julien Villers wrote: Take-away: never shorten your method/function names :) I don't know, in this case I'd say the variable name is spot on ;-). Must be the only example in the code of a well named variable. I have such treasures as Function names: Function H_WriteRecord1() Function H_WriteRecord2() Function H_WriteRecord3() Note - those are the declarations as they appear. No return type given, all state passed in via global or module-level variables, and nothing to indicate what gets written, what the difference between the three variants is. I suspect "that nearly does what I want, I'll copy and paste it". I also like the "batchHeader" boolean that sometimes outputs a header when true, otherwise when false. I still can't work out the logic governing when the two forms are used. I suspect the originator may be a closet worshipper of The FSM[^]. I just wished he hadn't felt the need to spread noodly appendages through the code I'm now tasked with maintaining.
  • if .... else case

    com help
    11
    0 Votes
    11 Posts
    1 Views
    C
    Yep, you hit the nail on the head with that one. I have no clue why the original programmer didn't do that in the first place. I changed it to that, since it looks much cleaner. The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin
  • strange way to handle click event of button placed in GridView

    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • It's a jungle in there

    24
    0 Votes
    24 Posts
    3 Views
    F
    cpkilekofp wrote: Hmmm, does this count as a rant? :laugh: Oh definitely :laugh: . Please don't take this personally :) cpkilekofp wrote: the worst code was (and may still be) written in C/C++ Nobody said that the worse code seen was in VB. The joke was about how often the name Ugly Betty comes up whenever we are talking about ugly girls. "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
  • Every line makes me die a little more...

    7
    0 Votes
    7 Posts
    3 Views
    L
    Exactly what should have been done. I see the same pattern as you described. They use jQuery, so I dont understand why they can't even make it a one liner... ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))
  • The Perfect Loop

    collaboration code-review
    5
    0 Votes
    5 Posts
    0 Views
    T
    Don't mention that there's an error, just show him the code and ask him why he shouldn't be fired for being a total moron! If he is actually any good, he'll laugh about it and say, "Oh yeah, you're right, maybe you'll have to let me go!"
  • If not null, return value else return null

    database com hardware data-structures help
    3
    0 Votes
    3 Posts
    0 Views
    R
    lol The comments are priceless. I really hope you left them in. "You get that on the big jobs."
  • Infinite Loop

    com
    2
    0 Votes
    2 Posts
    0 Views
    G
    I'm sure I've done that one. More than once. Hangs head in shame... Software Zen: delete this;
  • SQL between

    sharepoint database
    11
    0 Votes
    11 Posts
    0 Views
    A
    Exactamundo. It should be [A,B) because those intervals can be put next to each other without overlap. I've had to deal with a few stored procs that have comments recording the changes from + ' 23:59' to + ' 23:59:59' to + ' 23:59:59.999' etc. as the edge cases were slowly uncovered. Curvature of the Mind now with 3D
  • 0 Votes
    12 Posts
    0 Views
    M
    What you have done here is what I used to call "brute-force" programming, since it was easier for me to begin with a "hard map" of repetitive data that I could use to hammer out working code, however inelegant. Later, I would identify the patterns, and commit the raw data statements to configurable loops which I would then integrate with the rest of my spaghetti. It took YEARS for me to learn to plan ahead, and when I least expected it, here comes OOP, Abstraction, Polymorphism, Inheritance, and all that that implies...So back to square one, and I found myself forced to embrace the Evil that is Microsoft. Your little program is FAR ahead of what I was doing at your age, because the tools you are using simply didn't exist back then. Graphics? We didn't need no stinkin' graphics!!! We had 6x9 hardware-generated character sets, all upper case, 40 columns, and two damn lines, if we were lucky. Ever tried to play Donky Kong on a line-printer? So forgive the harsh criticism doled out by some of these coders, keeping in mind that these forums host some of the best and most experienced software engineers on the planet, and that as a general rule engineers are not commonly known for their tact, social skills, or personal hygiene. Add to that the fact that many of these people make their living undoing the nightmares passed down to them from, shall we say, "less than marginally competent" programmers, and you can understand why some of them might seem unkind. Just listen to them, and avoid doing things that will get you banned, and before you know it your programming skills will increase exponentially, earning you a coveted spot where you can expect to receive unkind criticism for even the most brilliant code. They are, at least, responding with suggestions; in my opinion it is far worse to have your posts go entirely ignored. As long as you keep learning, refusing to be discouraged, and are capable of grasping the abstractions involved in advanced coding, while being able to tell the difference between unexpected behavior caused by your code vs. unexpected behavior induced by Microsoft bugs, YOUR generation will construct the applications that MY generation NEVER dreamed possible.
  • How to generate a menu [modified]

    javascript html tools tutorial question
    3
    0 Votes
    3 Posts
    0 Views
    T
    Really... Who said boys don't cry...
  • Comma operator considered harmful

    graphics game-dev question
    5
    0 Votes
    5 Posts
    1 Views
    B
    That's not really bad, to me. Initialising and updating two variables in a loop is one of the well understood allowed places to use a comma. The thing that's wrong with this code is that the 3x3 nature of the board should be a variable (or at least a constant), not in there as a magic number 5 times.
  • Or "Else"...

    help
    2
    0 Votes
    2 Posts
    0 Views
    W
    The "or else" my parents would use to threaten me! Glad to see it's made its way into the hall of shame. "I have a theory that the truth is never told during the nine-to-five hours. " — Hunter S. Thompson
  • Hall of Shame

    5
    0 Votes
    5 Posts
    0 Views
    T
    He just spoiled the spoiling