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.
  • 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
                        • 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

                          K Offline
                          K Offline
                          KP Lee
                          wrote on last edited by
                          #36

                          I have to admit, it took me a short while to see it. I was verifying parenthesis while thinking the compiler would have blown up if you forgot one. Then I had to go "DOH!" too.

                          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

                            A Offline
                            A Offline
                            Adriaan Davel
                            wrote on last edited by
                            #37

                            Happened to me in c++ as a student, nearly gave up programming because of it :)

                            ____________________________________________________________ Be brave little warrior, be VERY brave

                            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