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
  • Pass by value and pass by reference

    24
    0 Votes
    24 Posts
    20 Views
    B
    When the class object is passed into ChangeMyVar(MyClass objMyClass) it is passed by value. Saying it another way: a copy of the object is made and then used by the ChangeMyVar method. Since this is a copy any changes to it do not affect the original. Bill W
  • // Enforce Method Contract

    csharp php wpf com
    10
    0 Votes
    10 Posts
    3 Views
    B
    I have seen code where the standard practice was to leave in the // TODO: Add constructor logic here that the compiler puts in automatically. The folk that did it never saw a problem with doing that because they didn't use the Task list. I found it to be a problem as soon as I put in a useful TODO and it was overwhelmed my hundreds of pointless TODOs. Bill W
  • It's horrible

    javascript html tools question
    14
    0 Votes
    14 Posts
    12 Views
    B
    I have to agree. It just isn't that hard to properly format tag. Bill W
  • Lack of understanding about the XmlDocument (C#)

    csharp ruby xml json question
    8
    0 Votes
    8 Posts
    7 Views
    U
    Yes! buddy :-\
  • Why DataSet always returns null?

    help question
    23
    0 Votes
    23 Posts
    24 Views
    B
    This post is definitely in the correct forum. The poster knows what is wrong with the code. The person that is new to try/catch/finally doesn’t realize it yet ;)
  • Cobol Horror

    algorithms data-structures career
    14
    0 Votes
    14 Posts
    9 Views
    B
    It does look like she was trying to be very through, so I am not suprised that she accounted for leap years. What this really points out is that it is not enough for a programmer to be able to write code that works; we also have to be able to come up with fast and efficient ways to solve problems. Bill
  • The black hole

    question
    20
    0 Votes
    20 Posts
    2 Views
    B
    I often use read only Properties, but write only properties, while useful in a few rare instances, are usually not what you want to do.
  • 0 Votes
    9 Posts
    6 Views
    M
    You mean A.R.S.E.H.O.L.E., right? :laugh:
  • Finding a record by its primary key

    database sql-server sysadmin business help
    19
    0 Votes
    19 Posts
    13 Views
    L
    Transactions are a blessing. Writing code to undo all changes after an error is no fun at all. And how do you proceed when even more errors pop up while undoing things? Unfortunately you don't always have transactions. I'm working on a larger project that uses a MySql database for both low cost and speed. Using another table format would make transactions available, but also slow everything down in an unacceptable manner. So I guess, the only choice is dealing with some tight spots in the buisiness logic. A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
  • Practice safe programming !

    tutorial question code-review
    12
    0 Votes
    12 Posts
    5 Views
    J
    It's hardly the stack that'll contribute to your foot's annihilation in C++... -- Kein Mitleid Für Die Mehrheit
  • Calling a subroutine

    dotnet adobe data-structures json
    5
    0 Votes
    5 Posts
    6 Views
    T
    This processor does have a jump instruction, but putting everything in copy_flash would be better. And the assumption the the return address is at the top of the stack breaks when optimisation is not enabled. What registers can be changed by a function is irrelevant here. The question is what inline assembler is allowed to do, whilst Visual C++ will parse inline assembler to determine register usage, GCC will not. If one of the registers has been allocated for another purpose by the compiler, it will break. Neither Visual C++ or GCC guarantees that registers will remain unchanged between consecutive asm statements. If profiling is enabled this code will break.
  • Is this a coding horror?

    com question discussion
    20
    0 Votes
    20 Posts
    12 Views
    C
    Wow. This is a... (crystall ball) report query (Crystal XI?) for an Italian ERP, right? "Periodo consuntivo budget"? "Ordini di produzione" ? :D Looks like a some kind of analysis of production/orders vs. budget planned. Sorry for bad Italian... I'm just a Romanian guy that happened to work for an Italian ERP for almost 10 years... Nuclear launch detected
  • 4096 Columns should be enough for anyone.

    csharp asp-net database oracle com
    22
    0 Votes
    22 Posts
    15 Views
    C
    For 1000 columns, all can be done is to emit a fatwa for the db "architect". ("Tell me, people, am I going insane?" - Black Sabbath - Sabotage, 1975, "Am I going insane (Radio)"). Nuclear launch detected
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • Ran across this sql the other day.

    database sql-server sysadmin tools
    7
    0 Votes
    7 Posts
    6 Views
    M
    We used to have a standard stored procedure that did that. I pointed out that a successful 'ping' didn't mean anything at all: the server could be down or the connection lost by the time that the next call was made. It's been phased out. Someone did claim that there was a problem with some old version of ADO that wouldn't return the results of the first stored procedure call you made after connecting, and so you called a dummy procedure before what you actually wanted to do. I'm skeptical - I've never seen a bug report on that. It smells of cargo-cult programming, and of the worst kind: chinese-whispers cargo-cult programming, where the implementor has heard that there's a problem and has heard that this will fix it, but has not experienced the problem themselves. DoEvents: Generating unexpected recursion since 1991
  • read file from bottom

    help question
    20
    0 Votes
    20 Posts
    10 Views
    D
    Just read the file into an array of lines, and loop backwards to the first occurrence of the delimiter (exit 1), keep track of the index you found and go from there. Dybs
  • Padding an ID to six digits

    ruby
    14
    0 Votes
    14 Posts
    16 Views
    D
    The System.String class has a nice little pair of PadLeft()/PadRight() functions. All it needs is the character to use for padding, and the final length the string needs to be, so that whole switch could be replaced with const int FIXED_LENGTH = 6; str = str->PadLeft('0', FIXED_LENGTH); Dybs
  • Code which caused my PC hang [modified]

    16
    0 Votes
    16 Posts
    14 Views
    N
    Surely running in safe mode would give you the chance to correct this
  • [Message Deleted]

    10
    0 Votes
    10 Posts
    4 Views
    L
    Maybe a person who should not see this post actually did... Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
  • Boolean Variable Name

    question
    16
    0 Votes
    16 Posts
    4 Views
    L
    Agreement is the best conclusion we can reach. :) Until next time then. A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.