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. When to check for null ?

When to check for null ?

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharplinqasp-netdatabasearchitecture
32 Posts 10 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.
  • S Offline
    S Offline
    Sasha Laurel
    wrote on last edited by
    #1

    Another project from our "star" developer who is apparently beyond contempt in every way. I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages. That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all! Here is an example to help you understand (table/field names changed slightly to protect the guilty):

    Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = \_
                From t In baseQuery
                Join tji In dataContext.OtherTransactionItems \_
                    On tji.SomeTransactionID Equals t.ID
                Where (t.LastUpdatedDate >= startDate \_
                       And t.LastUpdatedDate < endDate) \_
                    And (tji.Type = "Part") \_
                    And (tji.TotalDue <> 0)
                Select tji
    

    LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that. I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

    B J B P K 5 Replies Last reply
    0
    • S Sasha Laurel

      Another project from our "star" developer who is apparently beyond contempt in every way. I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages. That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all! Here is an example to help you understand (table/field names changed slightly to protect the guilty):

      Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = \_
                  From t In baseQuery
                  Join tji In dataContext.OtherTransactionItems \_
                      On tji.SomeTransactionID Equals t.ID
                  Where (t.LastUpdatedDate >= startDate \_
                         And t.LastUpdatedDate < endDate) \_
                      And (tji.Type = "Part") \_
                      And (tji.TotalDue <> 0)
                  Select tji
      

      LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that. I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

      B Offline
      B Offline
      Brisingr Aerowing
      wrote on last edited by
      #2

      X| And to those who will start the VB vs. C# debate, it is not VB that it the problem. The Problem exists between the chair and the keyboard. (AKA, PEBKAC)

      Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]

      S L 2 Replies Last reply
      0
      • B Brisingr Aerowing

        X| And to those who will start the VB vs. C# debate, it is not VB that it the problem. The Problem exists between the chair and the keyboard. (AKA, PEBKAC)

        Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]

        S Offline
        S Offline
        Sasha Laurel
        wrote on last edited by
        #3

        PEBKAC ! I had forgotten about that one, thanks for reminding me. Yes, I would say that is usually a problem with computers. Also, thanks for reading my rant it makes me feel like at least someone listened. As for the C# vs. VB debates, I don't really mind. It really gets so funny at times (people will argue the silliest things based on ideas that aren't even true). There is no problem with VB.Net especially for those of us who code using 'Option Strict On' (I'm really biased towards static typing). I find VB preferable because of the way you can easily tell where each block begins and ends. Doing so with this is hard for me: {{{{{{{{{{}}}}}}}}}} :confused:

        B 1 Reply Last reply
        0
        • B Brisingr Aerowing

          X| And to those who will start the VB vs. C# debate, it is not VB that it the problem. The Problem exists between the chair and the keyboard. (AKA, PEBKAC)

          Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]

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

          You are wrong. VB is the problem. It was always sold as sooooo easy to learn and use and then remained the safe harbor for all the horror coders they had picked up. A kind of Jurassic Park for coders. Give a user a program and he can work for a day. Show the user how to program and you have work for the rest of your life.

          At least artificial intelligence already is superior to natural stupidity

          J S A 3 Replies Last reply
          0
          • L Lost User

            You are wrong. VB is the problem. It was always sold as sooooo easy to learn and use and then remained the safe harbor for all the horror coders they had picked up. A kind of Jurassic Park for coders. Give a user a program and he can work for a day. Show the user how to program and you have work for the rest of your life.

            At least artificial intelligence already is superior to natural stupidity

            J Offline
            J Offline
            Julien Villers
            wrote on last edited by
            #5

            CDP1802 wrote:

            Give a user a program and he can work for a day. Show the user how to program and you have work for the rest of your life.

            Love that one :)

            'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

            L 1 Reply Last reply
            0
            • J Julien Villers

              CDP1802 wrote:

              Give a user a program and he can work for a day. Show the user how to program and you have work for the rest of your life.

              Love that one :)

              'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

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

              But please don't get me wrong. I have met people who taught themselves and also were very capable of logical thinking. Once a mailman (who only had some experience on a C64) told me about the bugs in a Win32 program, where to look in the code and how to fix them. And then there is that great mass of users who think they know everything...

              At least artificial intelligence already is superior to natural stupidity

              J 1 Reply Last reply
              0
              • L Lost User

                But please don't get me wrong. I have met people who taught themselves and also were very capable of logical thinking. Once a mailman (who only had some experience on a C64) told me about the bugs in a Win32 program, where to look in the code and how to fix them. And then there is that great mass of users who think they know everything...

                At least artificial intelligence already is superior to natural stupidity

                J Offline
                J Offline
                Julien Villers
                wrote on last edited by
                #7

                Yup, I've got some mixed experiences too: on the one hand self-taught guy who did great complicated stuff, like expert systems, AI, etc... and on the other hand supposedly 'educated' engineers who couldn't tell a variable from an instruction. And users, ah users, ...

                'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

                1 Reply Last reply
                0
                • S Sasha Laurel

                  PEBKAC ! I had forgotten about that one, thanks for reminding me. Yes, I would say that is usually a problem with computers. Also, thanks for reading my rant it makes me feel like at least someone listened. As for the C# vs. VB debates, I don't really mind. It really gets so funny at times (people will argue the silliest things based on ideas that aren't even true). There is no problem with VB.Net especially for those of us who code using 'Option Strict On' (I'm really biased towards static typing). I find VB preferable because of the way you can easily tell where each block begins and ends. Doing so with this is hard for me: {{{{{{{{{{}}}}}}}}}} :confused:

                  B Offline
                  B Offline
                  Brisingr Aerowing
                  wrote on last edited by
                  #8

                  I always have Option Strict On, and a lot of VB projects I download from different sites won't compile with it on, so I modify them to compile.

                  Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]

                  1 Reply Last reply
                  0
                  • L Lost User

                    You are wrong. VB is the problem. It was always sold as sooooo easy to learn and use and then remained the safe harbor for all the horror coders they had picked up. A kind of Jurassic Park for coders. Give a user a program and he can work for a day. Show the user how to program and you have work for the rest of your life.

                    At least artificial intelligence already is superior to natural stupidity

                    S Offline
                    S Offline
                    Sasha Laurel
                    wrote on last edited by
                    #9

                    Quote:

                    You are wrong. VB is the problem.

                    I'm afraid not. Go ahead and open your mouth and insert your shoe. In this case it is a combination of ignorance and arrogance that is the problem (something that you also seem to be displaying by this comment). Since you know so much about the culture of my workplace, why don't you expound upon that?

                    L 1 Reply Last reply
                    0
                    • L Lost User

                      You are wrong. VB is the problem. It was always sold as sooooo easy to learn and use and then remained the safe harbor for all the horror coders they had picked up. A kind of Jurassic Park for coders. Give a user a program and he can work for a day. Show the user how to program and you have work for the rest of your life.

                      At least artificial intelligence already is superior to natural stupidity

                      A Offline
                      A Offline
                      Andrei Straut
                      wrote on last edited by
                      #10

                      CDP1802 wrote:

                      You are wrong. VB PHP is the problem

                      FTFY :laugh: On a more serious note, I don't think any language is the problem. The problem is the people using them...

                      L 1 Reply Last reply
                      0
                      • S Sasha Laurel

                        Another project from our "star" developer who is apparently beyond contempt in every way. I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages. That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all! Here is an example to help you understand (table/field names changed slightly to protect the guilty):

                        Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = \_
                                    From t In baseQuery
                                    Join tji In dataContext.OtherTransactionItems \_
                                        On tji.SomeTransactionID Equals t.ID
                                    Where (t.LastUpdatedDate >= startDate \_
                                           And t.LastUpdatedDate < endDate) \_
                                        And (tji.Type = "Part") \_
                                        And (tji.TotalDue <> 0)
                                    Select tji
                        

                        LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that. I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

                        J Offline
                        J Offline
                        Jasmine2501
                        wrote on last edited by
                        #11

                        Just fix your stored procedures so they don't return nulls.

                        S 1 Reply Last reply
                        0
                        • J Jasmine2501

                          Just fix your stored procedures so they don't return nulls.

                          S Offline
                          S Offline
                          Sasha Laurel
                          wrote on last edited by
                          #12

                          That's a great idea. Now if only I had the access to do that...

                          A 1 Reply Last reply
                          0
                          • A Andrei Straut

                            CDP1802 wrote:

                            You are wrong. VB PHP is the problem

                            FTFY :laugh: On a more serious note, I don't think any language is the problem. The problem is the people using them...

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

                            PHP? That's Triassic Park! :) Every language may have a share of bad coders, but some have been advertised to them as being especially 'easy to learn'. They were called and they came. The languages may have evolved over time, but many of the coders have not.

                            At least artificial intelligence already is superior to natural stupidity

                            1 Reply Last reply
                            0
                            • S Sasha Laurel

                              That's a great idea. Now if only I had the access to do that...

                              A Offline
                              A Offline
                              Andrei Straut
                              wrote on last edited by
                              #14

                              Sasha Laurel wrote:

                              That's a great idea. Now if only I had the access to do that...

                              In this case, yes, suicide is a very tempting alternative. Homicide, on the other hand, mmm... ;) ;)...sweet I've found a nice way to punish the original coders when I come across stuff like this. Ask them what they intended to do in that portion(s) of the code, and WHY they did it so. It's not offensive, and it's perfectly justifiable. Now, one of two things may happen: - You, made to look like a fool if they can come up with a good explanation why they did what they did (which is ok with me, 'cause at least I can understand, and I don't mind admitting sometimes I'm just plain dumb), or - The 'WTF-did-I-do-here-can't-remember-can't-justify look on their faces, which is purely priceless (it may not help in untangling that code, but my ego will feel a really nice tickle-tingle) Now, in your specific case, I have no idea what would help, short of modifying the whole codebase :( :(

                              1 Reply Last reply
                              0
                              • S Sasha Laurel

                                Another project from our "star" developer who is apparently beyond contempt in every way. I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages. That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all! Here is an example to help you understand (table/field names changed slightly to protect the guilty):

                                Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = \_
                                            From t In baseQuery
                                            Join tji In dataContext.OtherTransactionItems \_
                                                On tji.SomeTransactionID Equals t.ID
                                            Where (t.LastUpdatedDate >= startDate \_
                                                   And t.LastUpdatedDate < endDate) \_
                                                And (tji.Type = "Part") \_
                                                And (tji.TotalDue <> 0)
                                            Select tji
                                

                                LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that. I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

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

                                This is probably actually Microsoft's fault: a Linq query should work the same for a query against the database, or a query against an in-memory object that was created by evaluating a Linq query on that same database.

                                S 1 Reply Last reply
                                0
                                • B BobJanova

                                  This is probably actually Microsoft's fault: a Linq query should work the same for a query against the database, or a query against an in-memory object that was created by evaluating a Linq query on that same database.

                                  S Offline
                                  S Offline
                                  Sasha Laurel
                                  wrote on last edited by
                                  #16

                                  Interesting idea! I wonder what the implications would be for an IQueryable provider. Oh well, I'm mostly just wanting to piss and moan at the moment.. ;)

                                  1 Reply Last reply
                                  0
                                  • S Sasha Laurel

                                    Another project from our "star" developer who is apparently beyond contempt in every way. I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages. That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all! Here is an example to help you understand (table/field names changed slightly to protect the guilty):

                                    Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = \_
                                                From t In baseQuery
                                                Join tji In dataContext.OtherTransactionItems \_
                                                    On tji.SomeTransactionID Equals t.ID
                                                Where (t.LastUpdatedDate >= startDate \_
                                                       And t.LastUpdatedDate < endDate) \_
                                                    And (tji.Type = "Part") \_
                                                    And (tji.TotalDue <> 0)
                                                Select tji
                                    

                                    LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that. I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

                                    P Offline
                                    P Offline
                                    Paul Conrad
                                    wrote on last edited by
                                    #17

                                    Sasha Laurel wrote:

                                    Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

                                    No, just consider it job security :rolleyes:

                                    "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                                    S 1 Reply Last reply
                                    0
                                    • P Paul Conrad

                                      Sasha Laurel wrote:

                                      Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

                                      No, just consider it job security :rolleyes:

                                      "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                                      S Offline
                                      S Offline
                                      Sasha Laurel
                                      wrote on last edited by
                                      #18

                                      Job Security! Just the positive spin that I needed. Thank you sir!

                                      P K 2 Replies Last reply
                                      0
                                      • S Sasha Laurel

                                        Job Security! Just the positive spin that I needed. Thank you sir!

                                        P Offline
                                        P Offline
                                        Paul Conrad
                                        wrote on last edited by
                                        #19

                                        Sasha, you might have to keep reminding higher up management that it will take time to eventually get it all taken care of if they start playing whiny games about it taking time.

                                        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                                        1 Reply Last reply
                                        0
                                        • S Sasha Laurel

                                          Another project from our "star" developer who is apparently beyond contempt in every way. I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages. That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all! Here is an example to help you understand (table/field names changed slightly to protect the guilty):

                                          Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = \_
                                                      From t In baseQuery
                                                      Join tji In dataContext.OtherTransactionItems \_
                                                          On tji.SomeTransactionID Equals t.ID
                                                      Where (t.LastUpdatedDate >= startDate \_
                                                             And t.LastUpdatedDate < endDate) \_
                                                          And (tji.Type = "Part") \_
                                                          And (tji.TotalDue <> 0)
                                                      Select tji
                                          

                                          LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that. I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

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

                                          Sasha Laurel wrote:

                                          Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?

                                          Depends on what you call viable. If you want to get out of this problem as quickly as possible, no matter the cost, then yes. Personally, I'd say the cost is too high to consider it. :-D (That's disregarding the subsequent funeral costs you'll impose on someone else.) PS your quote had really weird markups that I haven't seen code project do before. I stripped the verbose "span" markup surrounding every lower-case "i" in your note.

                                          S 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