Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. DOH!!!

DOH!!!

Scheduled Pinned Locked Moved The Lounge
helpquestionbeta-testing
37 Posts 23 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Kevin Marois

    This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

    private void DeleteSelectedRows()
    {
    if (accountsUltraGrid.Selected.Rows.Count > 0)
    {
    string message = "Are you sure you want to delete the selected accounts?";
    if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
    {
    foreach (var gridRow in accountsUltraGrid.Selected.Rows)
    {
    Account account = gridRow.ListObject as Account;

                host.GetProxy().DeleteAccount(account);
                totalRowCount--;
            }
        }
    }
    

    }

    If it's not broken, fix it until it is

    J Offline
    J Offline
    Jan Steyn
    wrote on last edited by
    #16

    Sitting on the fence between C# and VB.NET, I can only say that this is one of the mistakes that are impossible to make in VB.NET!!! :laugh: :laugh: :laugh: ;P

    1 Reply Last reply
    0
    • L Lost User

      Chris Maunder wrote:

      [beer] time.

      Schmiddy of light?

      Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #17

      Shandy

      L 1 Reply Last reply
      0
      • L Lost User

        Shandy

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #18

        _Josh_ wrote:

        Shandy

        He's not going to be able to only target me now, you'll have to be in his sights.

        Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

        1 Reply Last reply
        0
        • K Kevin Marois

          This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

          private void DeleteSelectedRows()
          {
          if (accountsUltraGrid.Selected.Rows.Count > 0)
          {
          string message = "Are you sure you want to delete the selected accounts?";
          if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
          {
          foreach (var gridRow in accountsUltraGrid.Selected.Rows)
          {
          Account account = gridRow.ListObject as Account;

                      host.GetProxy().DeleteAccount(account);
                      totalRowCount--;
                  }
              }
          }
          

          }

          If it's not broken, fix it until it is

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #19

          Im surprised nobody has pointed out that the method you want is ShowDialog not Show

          OriginalGriffO 1 Reply Last reply
          0
          • J J4amieC

            Im surprised nobody has pointed out that the method you want is ShowDialog not Show

            OriginalGriffO Online
            OriginalGriffO Online
            OriginalGriff
            wrote on last edited by
            #20

            That might be because there is no MessageBox.ShowDialog method... :-D

            Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            J 1 Reply Last reply
            0
            • K Kevin Marois

              This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

              private void DeleteSelectedRows()
              {
              if (accountsUltraGrid.Selected.Rows.Count > 0)
              {
              string message = "Are you sure you want to delete the selected accounts?";
              if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
              {
              foreach (var gridRow in accountsUltraGrid.Selected.Rows)
              {
              Account account = gridRow.ListObject as Account;

                          host.GetProxy().DeleteAccount(account);
                          totalRowCount--;
                      }
                  }
              }
              

              }

              If it's not broken, fix it until it is

              OriginalGriffO Online
              OriginalGriffO Online
              OriginalGriff
              wrote on last edited by
              #21

              You do get a warning however:

              Warning 1 Possible mistaken empty statement

              This is why I run with "Treat Warnings as Errors" set to "All" - it catches these, and won't let me run until I fix 'em. (It also means I can't get away with missing out the XML comments because "I'll come back to them later", because I never do...)

              Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              1 Reply Last reply
              0
              • K Kevin Marois

                This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                private void DeleteSelectedRows()
                {
                if (accountsUltraGrid.Selected.Rows.Count > 0)
                {
                string message = "Are you sure you want to delete the selected accounts?";
                if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                {
                foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                {
                Account account = gridRow.ListObject as Account;

                            host.GetProxy().DeleteAccount(account);
                            totalRowCount--;
                        }
                    }
                }
                

                }

                If it's not broken, fix it until it is

                R Offline
                R Offline
                Rahul Rajat Singh
                wrote on last edited by
                #22

                I think the code is perfectly written. The developer must be a genius and realized why would i need a confirmation if the user has already choose to delete. So he placed an innocent looking message and a clever ; to achieve this. absolute genius I say. +5.

                Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.

                1 Reply Last reply
                0
                • K Kevin Marois

                  This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                  private void DeleteSelectedRows()
                  {
                  if (accountsUltraGrid.Selected.Rows.Count > 0)
                  {
                  string message = "Are you sure you want to delete the selected accounts?";
                  if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                  {
                  foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                  {
                  Account account = gridRow.ListObject as Account;

                              host.GetProxy().DeleteAccount(account);
                              totalRowCount--;
                          }
                      }
                  }
                  

                  }

                  If it's not broken, fix it until it is

                  M Offline
                  M Offline
                  megaadam
                  wrote on last edited by
                  #23

                  Your tagline alone deserves a 5.

                  Life is too shor

                  1 Reply Last reply
                  0
                  • K Kevin Marois

                    This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                    private void DeleteSelectedRows()
                    {
                    if (accountsUltraGrid.Selected.Rows.Count > 0)
                    {
                    string message = "Are you sure you want to delete the selected accounts?";
                    if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                    {
                    foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                    {
                    Account account = gridRow.ListObject as Account;

                                host.GetProxy().DeleteAccount(account);
                                totalRowCount--;
                            }
                        }
                    }
                    

                    }

                    If it's not broken, fix it until it is

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #24

                    As no one else has pointed it out, where were the unit tests? A comprehensive test would have picked this up long before.

                    *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                    CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                    L B 2 Replies Last reply
                    0
                    • P Pete OHanlon

                      As no one else has pointed it out, where were the unit tests? A comprehensive test would have picked this up long before.

                      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #25

                      Pete O'Hanlon wrote:

                      As no one else has pointed it out, where were the unit tests? A comprehensive test would have picked this up long before.

                      Does scrum or agile have unit tests?

                      Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

                      P 1 Reply Last reply
                      0
                      • K Kevin Marois

                        This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                        private void DeleteSelectedRows()
                        {
                        if (accountsUltraGrid.Selected.Rows.Count > 0)
                        {
                        string message = "Are you sure you want to delete the selected accounts?";
                        if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                        {
                        foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                        {
                        Account account = gridRow.ListObject as Account;

                                    host.GetProxy().DeleteAccount(account);
                                    totalRowCount--;
                                }
                            }
                        }
                        

                        }

                        If it's not broken, fix it until it is

                        R Offline
                        R Offline
                        Rage
                        wrote on last edited by
                        #26

                        So now you know why you should not ignore warnings in production code.

                        ~RaGE();

                        I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Do not feed the troll ! - Common proverb

                        1 Reply Last reply
                        0
                        • P Pete OHanlon

                          As no one else has pointed it out, where were the unit tests? A comprehensive test would have picked this up long before.

                          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                          B Offline
                          B Offline
                          BobJanova
                          wrote on last edited by
                          #27

                          Unit testing user interface is hard and generally missed out. Since the bug was actually in the line that checked the UI response I can see how this could easily slip through testing.

                          P 1 Reply Last reply
                          0
                          • L Lost User

                            Pete O'Hanlon wrote:

                            As no one else has pointed it out, where were the unit tests? A comprehensive test would have picked this up long before.

                            Does scrum or agile have unit tests?

                            Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #28

                            Yes.

                            *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                            "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                            CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                            1 Reply Last reply
                            0
                            • K Kevin Marois

                              This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                              private void DeleteSelectedRows()
                              {
                              if (accountsUltraGrid.Selected.Rows.Count > 0)
                              {
                              string message = "Are you sure you want to delete the selected accounts?";
                              if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                              {
                              foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                              {
                              Account account = gridRow.ListObject as Account;

                                          host.GetProxy().DeleteAccount(account);
                                          totalRowCount--;
                                      }
                                  }
                              }
                              

                              }

                              If it's not broken, fix it until it is

                              B Offline
                              B Offline
                              BobJanova
                              wrote on last edited by
                              #29

                              I think we've all done something similar. But this is a compiler warning, certainly in C# (actually I think I remember it being so all the way back to the Zortech ANSI C compiler I used to use aged 10), so you should have caught it.

                              1 Reply Last reply
                              0
                              • B BobJanova

                                Unit testing user interface is hard and generally missed out. Since the bug was actually in the line that checked the UI response I can see how this could easily slip through testing.

                                P Offline
                                P Offline
                                Pete OHanlon
                                wrote on last edited by
                                #30

                                And this is why I love working with MVVM and WPF - that wouldn't have been user interface code (and it didn't actually need to be there in this case either).

                                *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                B 1 Reply Last reply
                                0
                                • P Pete OHanlon

                                  And this is why I love working with MVVM and WPF - that wouldn't have been user interface code (and it didn't actually need to be there in this case either).

                                  *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                  "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                  CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                  B Offline
                                  B Offline
                                  BobJanova
                                  wrote on last edited by
                                  #31

                                  Surely whatever framework you're using you're going to have a line like

                                  if(DialogResult.Yes == MessageBox.Show( ... )){
                                  modelView.DoDeleteRows(selectedRows);
                                  }

                                  ... in the UI layer? User confirmation in the UI is part of the requirement here. If you screw up that line, which is what happened here, your model-view and model code can be as perfect and as tested as you like and you can still make this mistake.

                                  P 1 Reply Last reply
                                  0
                                  • B BobJanova

                                    Surely whatever framework you're using you're going to have a line like

                                    if(DialogResult.Yes == MessageBox.Show( ... )){
                                    modelView.DoDeleteRows(selectedRows);
                                    }

                                    ... in the UI layer? User confirmation in the UI is part of the requirement here. If you screw up that line, which is what happened here, your model-view and model code can be as perfect and as tested as you like and you can still make this mistake.

                                    P Offline
                                    P Offline
                                    Pete OHanlon
                                    wrote on last edited by
                                    #32

                                    Nope. I'd use Dependency Injection to control the message box, so it would look something like this:

                                    IMessageBoxService mbox = ServiceContainer.Resolve();
                                    bool? result = mbox.Show("....")
                                    if (result.HasValue && result)
                                    {
                                    DeleteRows();
                                    }

                                    There's no need to have a selecteRows property because this would have been handled with the binding.

                                    *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                    CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                    1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      That might be because there is no MessageBox.ShowDialog method... :-D

                                      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                                      J Offline
                                      J Offline
                                      J4amieC
                                      wrote on last edited by
                                      #33

                                      You;re right I read it wrong. I thought the OP was opening a custom Form.

                                      1 Reply Last reply
                                      0
                                      • K Kevin Marois

                                        This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                                        private void DeleteSelectedRows()
                                        {
                                        if (accountsUltraGrid.Selected.Rows.Count > 0)
                                        {
                                        string message = "Are you sure you want to delete the selected accounts?";
                                        if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                                        {
                                        foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                                        {
                                        Account account = gridRow.ListObject as Account;

                                                    host.GetProxy().DeleteAccount(account);
                                                    totalRowCount--;
                                                }
                                            }
                                        }
                                        

                                        }

                                        If it's not broken, fix it until it is

                                        Z Offline
                                        Z Offline
                                        ZurdoDev
                                        wrote on last edited by
                                        #34

                                        The real question is how did that get out of development? Clearly no one actually tested it, right?

                                        There are only 10 types of people in the world, those who understand binary and those who don't.

                                        1 Reply Last reply
                                        0
                                        • K Kevin Marois

                                          This isn't a programming question. I wrote this, and just did a DOH!! Can you spot the bug? QA submitted a ticket say that when the Delete Account button was clicked, and the user click No when asked to confirm, it still deleted the row.

                                          private void DeleteSelectedRows()
                                          {
                                          if (accountsUltraGrid.Selected.Rows.Count > 0)
                                          {
                                          string message = "Are you sure you want to delete the selected accounts?";
                                          if (MessageBox.Show(message, "Delete Accounts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ;
                                          {
                                          foreach (var gridRow in accountsUltraGrid.Selected.Rows)
                                          {
                                          Account account = gridRow.ListObject as Account;

                                                      host.GetProxy().DeleteAccount(account);
                                                      totalRowCount--;
                                                  }
                                              }
                                          }
                                          

                                          }

                                          If it's not broken, fix it until it is

                                          B Offline
                                          B Offline
                                          Bernhard Hiller
                                          wrote on last edited by
                                          #35

                                          That's a pretty adequate programming style when you want to test your maintenance programmers. Hardly anyone will spot it.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups