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. Other Discussions
  3. The Weird and The Wonderful
  4. Nice catch!

Nice catch!

Scheduled Pinned Locked Moved The Weird and The Wonderful
debuggingquestion
18 Posts 8 Posters 130 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.
  • M Mike Dimmick

    Hint: use <pre> when formatting code - much more readable The .NET Framework does supply some operations to find out whether an operation is possible, rather than throw an exception in case of failure. In the case of the above code, you should use int.TryParse instead of Convert.ToInt32 (.NET 2.0 - in .NET 1.x you have to use Double.TryParse then cast to int), which will return a bool to indicate whether it could convert it. Lookups in a Hashtable will also throw an exception if the key isn't found. To avoid this, test for the presence of a key using ContainsKey. Exceptions are slow. Avoid them where not necessary.

    Stability. What an interesting concept. -- Chris Maunder

    W Offline
    W Offline
    webmarco
    wrote on last edited by
    #7

    Exactly my point, a catch block is to handle unexpected exceptions, not for program logic. If the exception is not being handled by the catch block, whats the point in using it? Thank you for your comment Mike.

    Regards, Marco

    1 Reply Last reply
    0
    • M Mike Dimmick

      Hint: use <pre> when formatting code - much more readable The .NET Framework does supply some operations to find out whether an operation is possible, rather than throw an exception in case of failure. In the case of the above code, you should use int.TryParse instead of Convert.ToInt32 (.NET 2.0 - in .NET 1.x you have to use Double.TryParse then cast to int), which will return a bool to indicate whether it could convert it. Lookups in a Hashtable will also throw an exception if the key isn't found. To avoid this, test for the presence of a key using ContainsKey. Exceptions are slow. Avoid them where not necessary.

      Stability. What an interesting concept. -- Chris Maunder

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #8

      Mike Dimmick wrote:

      Exceptions are slow.

      http://www.codeproject.com/dotnet/ExceptionPerformance.asp[^]

      Mike Dimmick wrote:

      Avoid them where not necessary.

      Well, yeah, but don't go out of your way to do so.

      --| "Every tool is a hammer." |--

      1 Reply Last reply
      0
      • A AnthonyC

        It is in Dutch. I have no problem reading it, and I don't even speak the language (2 minutes at Babelfish will do it). Get a Dutch programmer to translate it for you. Or does program code always have to be in English?:sigh:

        E Offline
        E Offline
        Erik Burger
        wrote on last edited by
        #9

        arc_10spd wrote:

        Or does program code always have to be in English?

        If you ever want to start a lobby for making a law that states that all code should be in English, I'll make the buttons :cool:

        A 1 Reply Last reply
        0
        • E Erik Burger

          arc_10spd wrote:

          Or does program code always have to be in English?

          If you ever want to start a lobby for making a law that states that all code should be in English, I'll make the buttons :cool:

          A Offline
          A Offline
          AnthonyC
          wrote on last edited by
          #10

          There are about currently about 4,000 unique languages remaining in the world. English will overrun most of them within the next 100 years at the cost of an extraordinary and fascinating diversity in human culture and history stretching back for over 10,000 years (at least that is what some historical linguists claim they can reconstruct). I for one would find it a tragedy if Dutch were to go as well ("not so much a language as an organised method for clearing one's throat"). However, ErikDD, if you MUST have it in English, here is a guess: .... try { int startNumber = Convert.ToInt32(dataGrid1[dataGrid1.CurrentRowIndex, 0]); Hashtable ht = Logic.ObtainTeamIDAtStartnumber(editID); teamID = (int) ht[Startnumber]; if (!Logic.IsTimeControlIntroduced(teamID) return; } catch { return; } ... ;P

          A E 2 Replies Last reply
          0
          • A AnthonyC

            There are about currently about 4,000 unique languages remaining in the world. English will overrun most of them within the next 100 years at the cost of an extraordinary and fascinating diversity in human culture and history stretching back for over 10,000 years (at least that is what some historical linguists claim they can reconstruct). I for one would find it a tragedy if Dutch were to go as well ("not so much a language as an organised method for clearing one's throat"). However, ErikDD, if you MUST have it in English, here is a guess: .... try { int startNumber = Convert.ToInt32(dataGrid1[dataGrid1.CurrentRowIndex, 0]); Hashtable ht = Logic.ObtainTeamIDAtStartnumber(editID); teamID = (int) ht[Startnumber]; if (!Logic.IsTimeControlIntroduced(teamID) return; } catch { return; } ... ;P

            A Offline
            A Offline
            AnthonyC
            wrote on last edited by
            #11

            Sorry. Probably should translate etappe as "stage": ... if (!Logic.IsTimeControlIntroduced(stageID) ... not ... if (!Logic.IsTimeControlIntroduced((editID)) ... :-O

            1 Reply Last reply
            0
            • A AnthonyC

              There are about currently about 4,000 unique languages remaining in the world. English will overrun most of them within the next 100 years at the cost of an extraordinary and fascinating diversity in human culture and history stretching back for over 10,000 years (at least that is what some historical linguists claim they can reconstruct). I for one would find it a tragedy if Dutch were to go as well ("not so much a language as an organised method for clearing one's throat"). However, ErikDD, if you MUST have it in English, here is a guess: .... try { int startNumber = Convert.ToInt32(dataGrid1[dataGrid1.CurrentRowIndex, 0]); Hashtable ht = Logic.ObtainTeamIDAtStartnumber(editID); teamID = (int) ht[Startnumber]; if (!Logic.IsTimeControlIntroduced(teamID) return; } catch { return; } ... ;P

              E Offline
              E Offline
              Erik Burger
              wrote on last edited by
              #12

              *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort :) As for Dutch disappearing, I wouldn't miss it, but I don't enjoy the prospect. It's just that I also believe in code mobility and reusability.

              P A 2 Replies Last reply
              0
              • E Erik Burger

                *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort :) As for Dutch disappearing, I wouldn't miss it, but I don't enjoy the prospect. It's just that I also believe in code mobility and reusability.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #13

                That would put a new spin on our local culture here outside Phoenix too; we just had our annual "Lost Dutchman Days" festival.

                --| "Every tool is a hammer." |--

                1 Reply Last reply
                0
                • W webmarco

                  Aha! so ignore any exception, just return. That is indeed the way to do it. Silly me, what was i thinking?:-O

                  Regards, Marco

                  J Offline
                  J Offline
                  JohnnySacks
                  wrote on last edited by
                  #14

                  Really, what were you thinking. Will the end user report any mysterious issues before you manage to get a new and better job? Besides, 'some day' we're going to integrate an error capture and/or logging methodology into this business critical high visibility application which re-engineers our business case to leverage best-practice synergies to pro actively actualize our bottom line but at this point we really don't know what features are required and we're REALLY in a hurry to get something done so for now, we'll just put the blocks in place and fill them in later. Every application I support in this place is filled with this crap. Every programmer who spews this crap out rapidly is a hero (and soon off to bigger and better jobs)

                  E 1 Reply Last reply
                  0
                  • E Erik Burger

                    *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort :) As for Dutch disappearing, I wouldn't miss it, but I don't enjoy the prospect. It's just that I also believe in code mobility and reusability.

                    A Offline
                    A Offline
                    AnthonyC
                    wrote on last edited by
                    #15

                    ErikDD wrote:

                    *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort

                    ErikDD, A hidden Dutchman! Very drole. And very hard to tell from your English, of course. I have always thought the Dutch speak the best English in Europe. BTW, how was my Dutch translation of the code? I speak English, French, German and two Australian Aboriginal languages, but alas no Dutch, which, if I could find the time I would try to learn. I also have only a Dutch to German phrase book (relic of a vacation in Amsterdam when I lived in Germany 20 years ago), so it was a bit tricky trying to put together a proper translation, and you don't get any nuances from Babelfish. Thanks for the sly humour! You definitely made me laugh. :laugh: Anthony

                    H E 2 Replies Last reply
                    0
                    • A AnthonyC

                      ErikDD wrote:

                      *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort

                      ErikDD, A hidden Dutchman! Very drole. And very hard to tell from your English, of course. I have always thought the Dutch speak the best English in Europe. BTW, how was my Dutch translation of the code? I speak English, French, German and two Australian Aboriginal languages, but alas no Dutch, which, if I could find the time I would try to learn. I also have only a Dutch to German phrase book (relic of a vacation in Amsterdam when I lived in Germany 20 years ago), so it was a bit tricky trying to put together a proper translation, and you don't get any nuances from Babelfish. Thanks for the sly humour! You definitely made me laugh. :laugh: Anthony

                      H Offline
                      H Offline
                      Hal Angseesing
                      wrote on last edited by
                      #16

                      arc_10spd wrote:

                      I have always thought the Dutch speak the best English in Europe

                      What better than the British? Yeah, you may have a point - have you heard some of our dialects! :-D

                      1 Reply Last reply
                      0
                      • A AnthonyC

                        ErikDD wrote:

                        *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort

                        ErikDD, A hidden Dutchman! Very drole. And very hard to tell from your English, of course. I have always thought the Dutch speak the best English in Europe. BTW, how was my Dutch translation of the code? I speak English, French, German and two Australian Aboriginal languages, but alas no Dutch, which, if I could find the time I would try to learn. I also have only a Dutch to German phrase book (relic of a vacation in Amsterdam when I lived in Germany 20 years ago), so it was a bit tricky trying to put together a proper translation, and you don't get any nuances from Babelfish. Thanks for the sly humour! You definitely made me laugh. :laugh: Anthony

                        E Offline
                        E Offline
                        Erik Burger
                        wrote on last edited by
                        #17

                        I wouldn't have guessed from your translation that you weren't a Dutch speaker, it was right on the mark :) As for the homour..I have my good days ;P Erik

                        1 Reply Last reply
                        0
                        • J JohnnySacks

                          Really, what were you thinking. Will the end user report any mysterious issues before you manage to get a new and better job? Besides, 'some day' we're going to integrate an error capture and/or logging methodology into this business critical high visibility application which re-engineers our business case to leverage best-practice synergies to pro actively actualize our bottom line but at this point we really don't know what features are required and we're REALLY in a hurry to get something done so for now, we'll just put the blocks in place and fill them in later. Every application I support in this place is filled with this crap. Every programmer who spews this crap out rapidly is a hero (and soon off to bigger and better jobs)

                          E Offline
                          E Offline
                          Erik Burger
                          wrote on last edited by
                          #18

                          JohnnySacks wrote:

                          Besides, 'some day' we're going to integrate an error capture and/or logging methodology into this business critical high visibility application which re-engineers our business case to leverage best-practice synergies to pro actively actualize our bottom line but at this point we really don't know what features are required and we're REALLY in a hurry to get something done so for now, we'll just put the blocks in place and fill them in later.

                          This sounds so scarily like my manager..no wonder we've decided not to listen to him anymore ;P

                          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