Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Coding Horror

Options
1181921232437

Comments

  • Technology & Internet Moderators Posts: 28,798 Mod ✭✭✭✭oscarBravo


    I started a new coding job a little over two decades ago. One of my first projects was to make some minor tweaks to a report that was used daily by the Finance department to keep track of the value of WIP raw materials, or "floor stock".

    This report had been written by my predecessor, who had been promoted off to another branch of this company in another country. I had been told many times that I had big shoes to fill, because he was such an excellent coder. It helped, of course, that he had originally moved to IT from the Finance department.

    So I waded into this report. Bear in mind, we're talking RPG IV on an IBM iSeries - not an easy language to write elegant code in at the best of times. I could barely decipher the code, never mind confidently modify it, so I asked the Finance guys to explain to me what the report did, and when I understood the output requirements, I simply re-wrote it, including the requested modifications. The agreed compromise was that both reports would be available until Finance could cross-check mine against the original to make sure it worked.

    The first morning they ran both reports, the Finance guy came to me shaking his head sadly: "your report is wrong". Pretty much every figure was slightly different from the original report, with some dramatic differences.

    So I spent the morning manually querying the database, hand-calculating several figures. I made a spreadsheet to demonstrate the detailed calculations for one particular entry, and demonstrated that my figures were correct. So, what was wrong with the old report?

    It took me a little while to figure it out. The report showed values in pounds and pence (pre-Euro, remember). Each figure was calculated by accumulating individual values, each in turn calculated by multiplying a potentially fractional quantity by a definitely fractional value... and each figure was rounded to the nearest penny before they were added up.

    The value that was most dramatically different? One of the raw materials was pure platinum, and they had been drastically mis-reporting the value of it that they had on hand for years.

    About the only consolation was the look on the Finance guy's face when I explained the flaw in his hero's code... (that, and the fact that my previous employer head-hunted me back a few months later!)


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,227 Mod ✭✭✭✭Capt'n Midnight


    Something I saw earlier today

    https://support.microsoft.com/en-us/kb/3053711
    In Windows 8.1, when the user account name contains the word "user", intermittently you will find the process taskhost.exe keeps consuming high CPU percentage.


    Go figure.


  • Registered Users Posts: 6,236 ✭✭✭Idleater



    Go figure.

    Interesting, yesterday I decided to google my high gnome-shell memory usage and found a thread basically saying it leaks ~2mb a minute depending on some undetermined other configuration.

    Sure enough after watching the memory clock up in the system monitor I installed the suggested workaround - xfce.


  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    Something I saw earlier today

    https://support.microsoft.com/en-us/kb/3053711


    Go figure.

    Id love to know what the code causing that looks like.


  • Registered Users Posts: 1,931 ✭✭✭PrzemoF


    Idleater wrote: »
    Interesting, yesterday I decided to google my high gnome-shell memory usage and found a thread basically saying it leaks ~2mb a minute depending on some undetermined other configuration.

    Sure enough after watching the memory clock up in the system monitor I installed the suggested workaround - xfce.

    Please report the memory leak - it's open source, so the feedback is essential.


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I've just been reading through these threads and something has dawned on me:
    var somefunction = function() {
       .. // Everything I've ever written that's more than six months old
    }
    
    

    The horror!

    The need to make short cuts when the pressure is on, poor decisions by myself, by management, by customers, lack of documentation, everything, it all leads to coding horrors.

    And to think that I could have been a pharmacist :rolleyes:


  • Closed Accounts Posts: 7,967 ✭✭✭Synode


    What's wrong with that code?


  • Registered Users Posts: 1,717 ✭✭✭Raging_Ninja


    Synode wrote: »
    What's wrong with that code?

    He's looking at all his old code and thinking "wtf was I smoking when committed this shít"


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    He's looking at all his old code and thinking "wtf was I smoking when committed this shít"

    Exactly.


  • Registered Users Posts: 5,560 ✭✭✭Slutmonkey57b


    I think it's worse when you see "ahhhh, look at this awful code" and your first thought is "****, I don't see anything wrong with it".


  • Advertisement
  • Registered Users Posts: 2,022 ✭✭✭Colonel Panic


    The real horror is it's Javascript.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    The real horror is it's Javascript.

    We're full-stack now you know!! :pac:


  • Registered Users Posts: 428 ✭✭[Rasta]


    private readonly string TWO_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 2);
    private readonly string FOUR_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 4);
    private readonly string SIX_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 6);
    private readonly string EIGHT_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 8);
    private readonly string TEN_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 10);
    

    :)


  • Registered Users Posts: 13,104 ✭✭✭✭djpbarry


    [Rasta] wrote: »
    private readonly string TWO_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 2);
    private readonly string FOUR_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 4);
    private readonly string SIX_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 6);
    private readonly string EIGHT_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 8);
    private readonly string TEN_SPACE_SPACER = new StringBuilder().insert(0, "nbsp;", 10);
    

    :)
    This made me feel a lot better about myself.


  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭croo


    yeah, that made me laugh too, another one from El Reg that caught my attention and gave me a chuckle...
    My mostly harmless favorite from the 1990s: a user prompt from global logistics system developed internally and rolled out to 30-plus countries.

    Are you sure you want to cancel the shipment?

    Yes / No / Cancel


    Tough question.


  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    croo wrote: »
    yeah, that made me laugh too, another one from El Reg that caught my attention and gave me a chuckle...

    haha. Ya that Yes/No/Cancel thing used to be a regular occurrence.


  • Closed Accounts Posts: 1,284 ✭✭✭Decent Skin


    haha. Ya that Yes/No/Cancel thing used to be a regular occurrence.

    Skype has (had?) a dialog box at one stage:

    "Are you sure you want to cancel the upload ?"

    The options underneath were "OK" and "Cancel"!


  • Registered Users Posts: 6,252 ✭✭✭Buford T Justice


            </div>
            <!--<div class="col-sm-12">-->
                <?php
                    if($type_id == 2) {
                        echo $this->Form->hidden('first_name', array(
                            'name' => 'first_name',
                            'value' => $data['Contact']['first_name'],
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    }
                    else {
                        echo $this->Form->input('first_name', array(
                            'name' => 'first_name',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    } ?>
            <!--</div>-->
            <div class="col-xs-12">
                <?php
                    if($type_id == 2) {
                        echo $this->Form->hidden('last_name', array(
                            'name' => 'last_name',
                            'value' => $data['Contact']['last_name'],
                        ));
                    }
                    else {
                        echo $this->Form->input('last_name', array(
                            'name' => 'last_name'
                        ));
                    }
                ?>
            </div>
            <!--<div class="col-sm-12">-->
                <?php
                    if($type_id == 2) {
                        echo $this->Form->hidden('phone', array(
                            'type' => 'tel',
                            'value' => $data['Contact']['phone'],
                            'name' => 'phone',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    }
                    else {
                        echo $this->Form->input('phone', array(
                            'type' => 'tel',
                            'name' => 'phone',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    } ?>
            <!--</div>-->
            <!--<div class="col-sm-12">-->
                <?php
                    if($type_id == 2) {
                        echo $this->Form->hidden('email', array(
                            'type' => 'email',
                            'value' => $data['Contact']['email'],
                            'name' => 'email',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    }
                    else {
                        echo $this->Form->input('email', array(
                            'type' => 'email',
                            'name' => 'email',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    } ?>
            <!--</div>-->
            <!--<div class="col-sm-12">-->
                <?php
                    if($type_id == 2) {
                        echo $this->Form->hidden('country_id', array(
                            'empty' => true,
                            'value' => $data['Contact']['country_id'],
                            'name' => 'country',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    }
                    else {
                        echo $this->Form->input('country_id', array(
                            'empty' => true,
                            'name' => 'country',
                            'div' => array(
                                'class' => 'form-inline col-xs-12 contact-us input-group-sm required'
                            )
                        ));
                    }
                ?>
            <!--</div>-->
    

    Countless form entries duplicated with individual if statements for each one, and only the default value of the form element that changes. There are so many different ways this can be done so much better.......

    Captain-Picard-Facepalm.jpg


  • Registered Users Posts: 7,814 ✭✭✭TPD


    Something I saw earlier today

    https://support.microsoft.com/en-us/kb/3053711


    Go figure.

    Not sure if its common, but we added a new guy to the network with 'bg' in his username. Windows 7 wouldn't let him log in until it was changed.


  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭croo


    TPD wrote: »
    Not sure if its common, but we added a new guy to the network with 'bg' in his username. Windows 7 wouldn't let him log in until it was changed.
    Could have been worse, I once installed windows on a PC for an elderly uncle named "Con". Naturally I created a user in his name. No warnings or errors on creation but the system was not stable. It took me days to figure out his name had a special meaning to windows.


  • Advertisement
  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,076 Mod ✭✭✭✭AlmightyCushion


    croo wrote: »
    Could have been worse, I once installed windows on a PC for an elderly uncle named "Con". Naturally I created a user in his name. No warnings or errors on creation but the system was not stable. It took me days to figure out his name had a special meaning to windows.

    My dad's name is Con as well. I was trying to create a folder with his name for him on OneDrive and it wouldn't let me. I had no idea why, guess it must be for the same reason.


  • Registered Users Posts: 1,931 ✭✭✭PrzemoF


    I just tried to create a directory named Con on some sort of windows share (I've no idea about the details) and I got an error window: "Rename: The specified device name is invalid". Same for a normal file. I have to say that is hilarious! :-D

    P.S. Exercise for the reader: try to create directory "Con" on your desktop :-D

    Explanation: http://answers.microsoft.com/en-us/windows/forum/windows_7-files/why-cant-i-create-a-folder-with-name/23c86662-4988-4c7d-9c2d-3e33d4413de3?auth=1


  • Registered Users Posts: 2,149 ✭✭✭dazberry


    PrzemoF wrote: »
    CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9

    If you were feeling a bit naughty in the late 80s / early 90s - before BBS software caught up - you could upload a file naming it CLOCK$, crashing the host and bringing the BBS offline :eek:

    D.


  • Technology & Internet Moderators Posts: 28,798 Mod ✭✭✭✭oscarBravo


    PrzemoF wrote: »
    P.S. Exercise for the reader: try to create directory "Con" on your desktop :-D

    396315.png

    :pac:


  • Registered Users Posts: 1,463 ✭✭✭Anesthetize


    You can still create a directory called "Con" on your desktop in Windows using Cygwin or Git Bash.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,227 Mod ✭✭✭✭Capt'n Midnight


    Slightly off topic but back in the dark ages when Plan B didn't work and you were trying to get the SCSI or CDROM driver recognised.

    copy config.sys + con


  • Registered Users Posts: 797 ✭✭✭FobleAsNuck


    I'm still using

    copy con a.txt

    when I want to create&edit something when using command prompt


  • Registered Users Posts: 4 ballindud


    Anyone know of a free survey package that can be incorporated in emails?


  • Registered Users Posts: 1,931 ✭✭✭PrzemoF


    ballindud wrote: »
    Anyone know of a free survey package that can be incorporated in emails?
    Sounds like a horror, but not a coding horror. Try another part of boards.ie


  • Advertisement
  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    for (int x = 1; x <= itemCount; x++)
    {
        if ( ( x > 7 && x < 13 && x != 10 ) || x == 4 )
        {
            // Do Stuff
        }
    }
    

    Found this today with no comments about wtf those magic numbers represent.


Advertisement