CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    What gives you that sinking feeling when looking at code you have inherited?

    My favourite(???) so far today is seeing...

    // todo - fix this

    There was of course no indication of what should be fixed or why!
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Yep, Comments that suck, and variable naming conventions. You could pull out all your hair out of frustration

  3. #3
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Just found another one...

    // this will need modifying
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Is it multi-threaded code? My favorite comment was this:

    // Sleep here for 500ms, this seems to fix bug #XXXXX

    Viggy

  5. #5
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Nice one! I haven't had one of those.

    I once came across a macro defined something like this...

    Code:
    #define BOGO DoSomething1(); \
                 DoSomething2(); \     
                 return;
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: What gives you that sinking feeling when looking at code you have inherited?

    I once saw this in a student's work he submitted :

    Code:
    'This is my Comment
    I had to give him some points as he used the ' as well as knew ( at least ) that it was a comment. I gave hime 2 out of 5 though.

    See what I have to put up with on a daily basis? HAHAHA

  7. #7
    Join Date
    Jan 2010
    Posts
    1,133

    Re: What gives you that sinking feeling when looking at code you have inherited?

    So Hannes, it was something along these lines then:

    'This is my Comment
    'And this is my comment: 2/5!


  8. #8
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Code:
    // I wasn't sure how to use these (and too lazy to check), so something quick...
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  9. #9
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: What gives you that sinking feeling when looking at code you have inherited?

    And just saw:
    Code:
    // This "if" condition should be removed, but I just don't have time to wait for a complete rebuild
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  10. #10
    Join Date
    Feb 2002
    Posts
    4,640

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Years ago, I had worked with someone that came over from PASCAL. He used to do this:
    Code:
    #define { BEGIN
    #define } END
    at the top of his C files...

    Viggy

  11. #11
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Here's one from a Borland C 6 project i inherited.
    Code:
    void __fastcall TMasterRecipeForm::SpeedButton3Click(TObject *Sender)
    {
        // create a new recipe
        // use the username form for input, instead of creating a totally new form
        // - i'm lazy, i know (or is it good programming practice??, makes ya think)
    
        // create new username form for modification
        UsernameForm = new TUsernameForm(Application);
        AnsiString NewRecipe;
    
        if ( UsernameForm )
        {
            // do neccessary changes for input form
            UsernameForm->Label2->Caption = "Recipe :";
            UsernameForm->Caption = "Please specify new Recipe Name :";
    
            // show *modified* username form
            UsernameForm->ShowModal();
    and a little later in the same project..
    Code:
        // use the username form for input, instead of creating a totally new form
        // - i'm lazy, i know
    
        // create new username form for modification
        UsernameForm = new TUsernameForm(Application);
    
        if ( UsernameForm )
        {
            // do neccessary changes for input form
            UsernameForm->Label2->Caption = "Recipe :";
            UsernameForm->Caption = "Please specify new Recipe Name :";
    
            // show *modified* username form
            UsernameForm->ShowModal();
    and then further down...

    Code:
            // build sql query for new master recipe
            AnsiString SQL = "insert into ********* values( ";
            SQL += "'" + RecipeID + "', ";
            SQL += "'" + Recipe + "', ";
    
            // add field data to query *easier than doing each an every one manually*
            // Lazy and bad method .....
    
            for ( int c = 3; c < 66; c++ )
            {
                if ( c == 7 || c==8)
                {
                    if ( db->DataQuery->Fields->FieldByNumber(c)->AsString.AnsiCompareIC( "true" ) == 0 )
                        SQL += "1, ";
                    else
                        SQL += "0, ";
                    continue;
                }
    
                SQL += "'" + db->DataQuery->Fields->FieldByNumber(c)->AsString + "', ";
            }
    
            // final piece
            SQL += "'" + db->DataQuery->Fields->FieldByNumber(66)->AsString + "') ";
    and i cringed when i saw this one (still in the same file)
    Code:
            /* ********* list of things to delete **********
    
            SelectedFlourBunkers
            Mix Design
            Selected Remix Percentages
            Master Recipe Record
            Export Recipe List
    
            ************************************************/
    
            // get master recipe id
            // TODO : create seperate backup function for when changes are done
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  12. #12
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: What gives you that sinking feeling when looking at code you have inherited?

    VB6 Upgrade Wizard. Hated those:
    ******** Fix Stupid Net Framework Error in this line *************
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  13. #13
    Join Date
    Jan 2012
    Location
    toronto
    Posts
    13

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Quote Originally Posted by GremlinSA View Post
    Here's one from a Borland C 6 project i inherited.
    Code:
    void __fastcall TMasterRecipeForm::SpeedButton3Click(TObject *Sender)
    {
        // create a new recipe
        // use the username form for input, instead of creating a totally new form
        // - i'm lazy, i know (or is it good programming practice??, makes ya think)
    
        // create new username form for modification
        UsernameForm = new TUsernameForm(Application);
        AnsiString NewRecipe;
    
        if ( UsernameForm )
        {
            // do neccessary changes for input form
            UsernameForm->Label2->Caption = "Recipe :";
            UsernameForm->Caption = "Please specify new Recipe Name :";
    
            // show *modified* username form
            UsernameForm->ShowModal();
    It does indeed make me think...

  14. #14
    Join Date
    Feb 2002
    Posts
    4,640

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Recently, I saw something like this:
    Code:
    // Fix commented line below...
    That was the only comment in the function. Nothing else was commented out!

    Viggy

  15. #15
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: What gives you that sinking feeling when looking at code you have inherited?

    Quote Originally Posted by MrViggy View Post
    Recently, I saw something like this:
    Code:
    // Fix commented line below...
    That was the only comment in the function. Nothing else was commented out!
    ROFL ... thats a good one... So the Unknown problem must have been fixed..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured