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
  • To Self-Close the BR or Not to Close the BR

    question
    8
    0 Votes
    8 Posts
    0 Views
    B
    There is a semantic difference between <p> (or other similar elements like <pre> and <dd>) and <br> (and I don't just mean that one is a container tag and one is a separator). It's not just a matter of (ab)using styles to make one look like the other. A paragraph is one group of related text, which may have explicit line breaks (<br> or, if being XHTML compliant, <br/>) within it. <br> shouldn't be used to split paragraphs, any more than <p> should be used to cause an in-paragraph line break, even if you can mess with the styles so that is the appearance. (An exception would be code listings where it's usual to run the whole thing inside one <pre>, even though one could logically argue that it should be one per method.)
  • Jumping on the Band wagon

    asp-net csharp html
    3
    0 Votes
    3 Posts
    0 Views
    J
    "One can write Fortran in any language" Time you enjoy wasting is not wasted time - Bertrand Russel
  • Redundancy

    2
    0 Votes
    2 Posts
    0 Views
    R
    your not wRONG "You get that on the big jobs."
  • excel formula anyone

    question
    12
    0 Votes
    12 Posts
    0 Views
    S
    Whoever set up the spreadsheet originally simply plugged in standard accounting formulas without performing any simplification. Gross Profit Margin is defined as the difference between revenue and cost of goods sold, divided by the revenue: GPM = (Revenue - CoGS)/Revenue The equation in the spreadsheet you were looking at was looking at (effectively): (1 - GPM)\*100 True, it could have been simplified, but there are (at times) reasons for not performing every possible simplification. In this case, to someone who "thinks" in terms of CoGS, Revenue, Margins, etc. the equation given makes a lot of sense. To a programmer (or a mathmatician) it is not very efficient, but to the accountant it provides self-documenting code. This is especially important in Excel, where you can't add comments to the code (cell equation). It appears that they were trying to calculate the proportion of each dollar of revenue that the company spent as expenses.
  • Everything That Has a Beginning Has an End

    question
    2
    0 Votes
    2 Posts
    0 Views
    L
    Probably, the guy copied part of a code that belonged to an IF statement and forgot to remove the BEGIN.. END, he must have thought 'why disturb the code if it compiles well?'
  • Everything That Has a Beginning Has an End (Eventually)

    database csharp linq com
    23
    0 Votes
    23 Posts
    0 Views
    L
    icestatue wrote: We were able to shorten the script to about 12 lines of code when we finished it. :doh: How long these lines were? Greetings - Jacek
  • 558 Lines Of QuickBasic Glory

    com question
    25
    0 Votes
    25 Posts
    1 Views
    B
    Nuh uh. It's a grave accent. :-\
  • Check for True to return True...

    13
    0 Votes
    13 Posts
    0 Views
    L
    The next time someone tells you that true always returns true I want you to ask that person a question. Ask that person: Have you tested it? Frankly, when I see your code I see an excellent place to put a unit test. ;P
  • Unnecessary Commented Code

    sharepoint database tutorial
    11
    0 Votes
    11 Posts
    0 Views
    F
    I'll admit to leaving comments behind when I'm designing new stuff but want to be able to refer to the old stuff, but I only leave it there when I forget or get distracted before finishing the new function.
  • Found error 101 in my own code yesterday

    help
    8
    0 Votes
    8 Posts
    0 Views
    F
    This, ladies and gentlemen, is the Dunning-Kruger effect in action.
  • Seriously? Why write it yourself

    csharp javascript question
    7
    0 Votes
    7 Posts
    0 Views
    T
    fine to me - I can handle a 13. pay check :rolleyes: regards Torsten I never finish anyth...
  • This code may not quite do what it says it does.

    ruby regex
    25
    0 Votes
    25 Posts
    2 Views
    L
    this made my day
  • I feel dirty [modified]

    csharp css visual-studio winforms collaboration
    2
    0 Votes
    2 Posts
    0 Views
    B
    We had this very issue the other day on my team. And several other issues on my previous project related to data binding. Yes, the DGV seems to have been written by an idiot.
  • Spotted on The Daily WPF...

    csharp wpf com
    13
    0 Votes
    13 Posts
    0 Views
    B
    Abbreviations.
  • What If

    asp-net csharp javascript com
    14
    0 Votes
    14 Posts
    0 Views
    K
    Ahhh, a Clinton supporter!
  • Try again...

    design algorithms
    3
    0 Votes
    3 Posts
    0 Views
    0
    Thanks, for the advice... it almost makes too much sense. Why didn't I think of that? I'm never going to put my own code in 'clever code', seriously if I ever write something clever it'll be because I stole the idea. ;P Right now I got what it supposed to be doing, it's exactly the same idea but it has a better structure. I use one "if block" to gather information where the walls are, put the result in a byte and run it through a "select" block where every "case" evaluates the direction of the player. It's more readable and a lot easier (as in, not impossible) to comment on. I'm getting more ambitious now and I'd like to try some ideas for more complex behavior, based on your suggestion. It also needs to be able to run through any given maze, right now I'm 'cheating' because the navigation is tailored to the only maze in the game. The project started as a break from the boring database stuff at the job training center, so I didn't have much time to work on it. The rest of the game is only about 200 lines of code and it didn't took long to write, but to get decent enemies working proves to be quite a challenge. Giraffes are not real.
  • The Engineer (wears a cowboy hat)

    javascript
    8
    0 Votes
    8 Posts
    0 Views
    R
    Interesting approach that dll idea. I think we'll work on that :laugh: "You get that on the big jobs."
  • Lovely....

    javascript com help
    3
    0 Votes
    3 Posts
    0 Views
    D
    Wow...... I would never hire someone who wrote code like that.
  • The Whole Codebase I inherited [again]

    com
    12
    0 Votes
    12 Posts
    0 Views
    K
    JV9999 wrote: but there are far easier solutions for that which are also much more common. Kind of the definition of a coding Horror :) Sort of a cross between Lawrence of Arabia and Dilbert.[^] -Or- A Dead ringer for Kate Winslett[^]
  • Another coding horror

    17
    0 Votes
    17 Posts
    2 Views
    R
    Or even... void F() { Blackboard.WriteLine("I must not use unterminated recursion"); F(); } (Your version was unterminated iteration)