• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Code review - hilarious code snippets

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #51
    Originally posted by russell View Post
    Exactly my point, the .NET runtime protects you from all if the low level details where a badly written program could BSOD.
    .Net apps only run in user mode so you could argue quite legitimately that the windows runtime architecture protects you from BSOD rather than the programming environment.
    Knock first as I might be balancing my chakras.

    Comment


      #52
      Originally posted by russell View Post
      I doubt testing for null is an expensive operation and can probably be optimized by the compiler.
      You'd have thought.
      Knock first as I might be balancing my chakras.

      Comment


        #53
        Originally posted by suityou01 View Post
        What about encapsulation? You would want to take into your thoughts what happens to the caller if this goes bang? Using a try block with no exception being raised sounds dodgy IMVHO, and runs the risk of creating time bombs.

        Just sayin like
        What happens when it 'goes bang' is that you get an exception. The point is that when it doesn't then you only execute the try block, which is quicker than checking results for null every time.
        While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

        Comment


          #54
          There was a chap kicked out of the aerospace place I was at, it was all rather basic C. As you may imagine, aircraft software has to be very carefully controlled and you do only what is absolutely necessary according to the design spec but he was modding unrelated modules because he didn't like some name or whatever.
          bloggoth

          If everything isn't black and white, I say, 'Why the hell not?'
          John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

          Comment


            #55
            Originally posted by eek View Post
            That wasn't what he was saying. Its the cost of testing for null all the time compared to using a try block with an exception. I don't think anyone has suggested using a try block with no exception (until you arrived).
            Probably because the compiler won't let you write a try with no catch
            While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

            Comment


              #56
              Originally posted by doodab View Post
              What happens when it 'goes bang' is that you get an exception. The point is that when it doesn't then you only execute the try block, which is quicker than checking results for null every time.
              unhandled exception
              Knock first as I might be balancing my chakras.

              Comment


                #57
                Originally posted by doodab View Post
                Testing for a null result is more expensive than a try block if no exception is raised
                Originally posted by suityou01 View Post
                Post 44, paragraph 1, sentence 2, clause 1.

                HTH BIDI
                Is not suggesting you create a try block with no exception capture its a statement on whether a try block is more expansive than testing for a null result.
                merely at clientco for the entertainment

                Comment


                  #58
                  Originally posted by doodab View Post
                  Probably because the compiler won't let you write a try with no catch
                  But it will let you write an empty catch. Hence "raising a try without raising an exception" made me raise my eyebrows.
                  Knock first as I might be balancing my chakras.

                  Comment


                    #59
                    Originally posted by eek View Post
                    Is not suggesting you create a try block with no exception capture its a statement on whether a try block is more expansive than testing for a null result.
                    And again in English
                    Knock first as I might be balancing my chakras.

                    Comment


                      #60
                      Originally posted by eek View Post
                      Is not suggesting you create a try block with no exception capture its a statement on whether a try block is more expansive than testing for a null result.
                      Exceptions should only be used for situations that you cannot foresee i.e. A external resource not being available, not for an empty search result from a query, the clue is in the name.

                      Comment

                      Working...
                      X