Ridiculous code

This is a discussion on Ridiculous code within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I saw the following identifier in code today: Interrupt_Order_Array_Index It was controlling a for loop. I can only assume that ...

  1. #1
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146

    Ridiculous code

    I saw the following identifier in code today:
    Interrupt_Order_Array_Index
    It was controlling a for loop. I can only assume that i took a day off.

    What ridiculous code do you have to work with?
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Or maybe they wanted something more meaningful then i

    Still its not as bad as hungrian notation

  3. #3
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    This is code to do polynomial regressions. It was origionally written in BASIC and no one has dared to try and make it more readable because they're afraid to break it (myself included).

    It's now in one of my VB apps, but ridiculous nonetheless:
    Code:
    A(1) = n
    For i = 1 To n
        xVal = x(i)
        yVal = y(i)
        For j = 2 To 2 * D + 1
            A(j) = A(j) + xVal ^ (j - 1)
        Next j
        For k = 1 To D + 1
            R(k, D + 2) = T(k) + yVal * xVal ^ (k - 1)
            T(k) = T(k) + yVal * xVal ^ (k - 1)
        Next k
        T(D + 2) = T(D + 2) + yVal ^ 2
    Next i
    
    For j = 1 To D + 1
        For k = 1 To D + 1
            R(j, k) = A(j + k - 1)
        Next k
    Next j
    For j = 1 To D + 1
        k = j
        For i = 1 To D + 2
            S = R(j, i)
            R(j, i) = R(k, i)
            R(k, i) = S
        Next i
        Z = 1 / R(j, j)
        For i = 1 To D + 2
            R(j, i) = Z * R(j, i)
        Next i
        For k = 1 To D + 1
            If k <> j Then
                Z = -R(k, j)
                For i = 1 To D + 2
                    R(k, i) = R(k, i) + Z * R(j, i)
                Next i
            End If
        Next k
    Next j
    
    C(D, 0) = R(1, D + 2)
    C(D, 1) = R(2, D + 2)
    C(D, 2) = R(3, D + 2)
    C(D, 3) = R(4, D + 2)
    C(D, 4) = R(5, D + 2)

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >>Still its not as bad as hungrian notation

    agreed.

  5. #5
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Bah...I like hungarian notation.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  6. #6
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    The only thing worse than hungarian notation (I like this version of it though: http://www.joelonsoftware.com/articles/Wrong.html) is when no one even follows the standards.

    We use some pretty basic guidelines at work. Classes should have all private member variables at the top, all in caMeL case and prefixed with an underscore. Next comes constructors, then public properties (in Pascal case), then class methods (private, then public). All variables and method parameters are in caMeL case. Pedantic? maybe. But when you open a source file and need to find something in a hurry, you can usually feel your way around a LOT faster if you know what order everything is declared. If you see anything in caMeL case, you know its a parameter or a variable. If you see something starting with an underscore, you know its a private member variable. Simple.

    But there is one guy who just doesn't follow standards. Not a bit. He doesn't use private members, doesn't use C# properties at all (just exposes public member variables, in caMeL case no less), and all his methods take parameters in Pascal case. And they're declared all over the place in the class file.

    I'm not saying our standard is the right way, but everyone else here uses it except him. He thinks he's Internet Explorer or something

    Edit: that same guy has been known to accidentally 'check out' all files from our SourceSafe repository, and go to lunch for long periods of time in the same day.
    Last edited by nickname_changed; 05-18-2005 at 08:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21