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. Put Your Code Window In the Upright and LOCKED Position

Put Your Code Window In the Upright and LOCKED Position

Scheduled Pinned Locked Moved The Lounge
databasedebugging
15 Posts 8 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.
  • N Offline
    N Offline
    nullGumby
    wrote on last edited by
    #1

    Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

    A C P J M 6 Replies Last reply
    0
    • N nullGumby

      Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

      A Offline
      A Offline
      amclint
      wrote on last edited by
      #2

      ROFL, MAN! This brings back nightmares of my old days migrating from MS Access to Oracle/SQL Server, some stuff programmed by secretaries and probably the janitorial staff it seemed like. Good luck! Glad it's not me...X|

      if (!interested){return false;} amclint

      1 Reply Last reply
      0
      • N nullGumby

        Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

        C Offline
        C Offline
        Christopher Duncan
        wrote on last edited by
        #3

        Perhaps they're just not professional software developers. Of course, that works out nicely for you, since it creates a demand for your talents.

        Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

        L 1 Reply Last reply
        0
        • C Christopher Duncan

          Perhaps they're just not professional software developers. Of course, that works out nicely for you, since it creates a demand for your talents.

          Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          ROTFLMAO When I saw the subject I thought it was about rotating your LCD Monitor 90 degrees. One of my colleagues does that. :laugh: Can you imagine how disappointed I was to get VBed? :(( [mod] Why does Bob keep misfiling my posts? :((

          Last modified: 29mins after originally posted -- DAMN YOU BOB!

          led mike

          1 Reply Last reply
          0
          • N nullGumby

            Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

            P Offline
            P Offline
            peterchen
            wrote on last edited by
            #5

            What is wrong with it? There ARE at least these three versions of what the user considers "empty" - and even when the data comes from some component, it takes wild guesses which of them is the "empty de jour". The names are silly, and IIRC VBA can do boolean assignments which would allow to reduce LOC (on the sake of readability for lesser skilled coworkers), but that's all not the end of good reason.


            We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
            Linkify! || Fold With Us! || sighist

            J 1 Reply Last reply
            0
            • P peterchen

              What is wrong with it? There ARE at least these three versions of what the user considers "empty" - and even when the data comes from some component, it takes wild guesses which of them is the "empty de jour". The names are silly, and IIRC VBA can do boolean assignments which would allow to reduce LOC (on the sake of readability for lesser skilled coworkers), but that's all not the end of good reason.


              We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
              Linkify! || Fold With Us! || sighist

              J Offline
              J Offline
              Jeremy Falcon
              wrote on last edited by
              #6

              peterchen wrote:

              What is wrong with it?

              You want the long answer or short? I don't know much VBA, but I know classic VB pretty darn well and this is code I'd also scoff at for several reasons. So, with that being said; short or long? :-D

              Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

              P 1 Reply Last reply
              0
              • N nullGumby

                Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

                J Offline
                J Offline
                Jeremy Falcon
                wrote on last edited by
                #7

                nullGumby wrote:

                I mean wtf.

                I so know how you feel. :laugh: VBers seem to really be bad at this crap. Yeah, bad code is everywhere, but I see it a LOT with VB. I mean really, it's like they barely learn how to program and consider themselves uber 1337 because they can make an ActiveX DLL (and mistakenly think it's a regular DLL to boot) to impress grandma who doesn't even know how to check email.

                Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                1 Reply Last reply
                0
                • J Jeremy Falcon

                  peterchen wrote:

                  What is wrong with it?

                  You want the long answer or short? I don't know much VBA, but I know classic VB pretty darn well and this is code I'd also scoff at for several reasons. So, with that being said; short or long? :-D

                  Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

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

                  long :) (I do have some VBA memories scars, so I might not be objective...)


                  We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                  Linkify! || Fold With Us! || sighist

                  J 1 Reply Last reply
                  0
                  • P peterchen

                    long :) (I do have some VBA memories scars, so I might not be objective...)


                    We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                    Linkify! || Fold With Us! || sighist

                    J Offline
                    J Offline
                    Jeremy Falcon
                    wrote on last edited by
                    #9

                    peterchen wrote:

                    long

                    That's what I was hoping for. :) I'll repost the code here just for reference's sake:

                    Public Function IsThere(what As Variant) As Boolean
                    IsThere = Not NotThere(what)
                    End Function

                    Public Function NotThere(what As Variant) As Boolean
                    If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then
                    NotThere = True
                    Else
                    NotThere = False
                    End If
                    End Function

                    I'll disregard naming conventions on this one.

                    1. IsThere and NotThere do the exact same thing, both of which return True or False if a passed variable is what they consider empty or not. This is ambiguous.
                    2. This ain’t C/C++, classic VB doesn’t short circuit, so if you don’t want all three of those checks to fire off every time regardless of the value passed, then don’t use it (personally I always make speed a consideration, and considering the goal of these routines I imagine they would be called often).
                    3. Don't compare against "" in VB unless you enjoy wasting 8 bytes of memory and an allocation time, compare against vbNullString instead.
                    4. Only use Trim$ when evaluating to a string for comparison rather than Trim, this saves time because VB won’t have to figure what to do with it.
                    5. Lastly, the use of these functions can most likely indicate the misuse of Variants. VB already provides simple checks for most data types, but as you can see the Variants take a bit more because of all the conditions they can meet. While this is no guarantee, it is indicative of what I've typically seen as Variant abuse and you loose what little type safety VB already has when doing it.

                    I think my biggest peeve with all of the VB hoopla is people want to call themselves professionals and don’t know the simple things about the environment they claim to be pros in. If the guy that wrote this was a new guy, so be it. But, I’d kindly let them know how/where things can be improved upon.

                    Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                    P 1 Reply Last reply
                    0
                    • J Jeremy Falcon

                      peterchen wrote:

                      long

                      That's what I was hoping for. :) I'll repost the code here just for reference's sake:

                      Public Function IsThere(what As Variant) As Boolean
                      IsThere = Not NotThere(what)
                      End Function

                      Public Function NotThere(what As Variant) As Boolean
                      If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then
                      NotThere = True
                      Else
                      NotThere = False
                      End If
                      End Function

                      I'll disregard naming conventions on this one.

                      1. IsThere and NotThere do the exact same thing, both of which return True or False if a passed variable is what they consider empty or not. This is ambiguous.
                      2. This ain’t C/C++, classic VB doesn’t short circuit, so if you don’t want all three of those checks to fire off every time regardless of the value passed, then don’t use it (personally I always make speed a consideration, and considering the goal of these routines I imagine they would be called often).
                      3. Don't compare against "" in VB unless you enjoy wasting 8 bytes of memory and an allocation time, compare against vbNullString instead.
                      4. Only use Trim$ when evaluating to a string for comparison rather than Trim, this saves time because VB won’t have to figure what to do with it.
                      5. Lastly, the use of these functions can most likely indicate the misuse of Variants. VB already provides simple checks for most data types, but as you can see the Variants take a bit more because of all the conditions they can meet. While this is no guarantee, it is indicative of what I've typically seen as Variant abuse and you loose what little type safety VB already has when doing it.

                      I think my biggest peeve with all of the VB hoopla is people want to call themselves professionals and don’t know the simple things about the environment they claim to be pros in. If the guy that wrote this was a new guy, so be it. But, I’d kindly let them know how/where things can be improved upon.

                      Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                      P Offline
                      P Offline
                      peterchen
                      wrote on last edited by
                      #10

                      (1) Kids program that way. Jumping though hoops to save three letters. I don't really care. Maybe they grow up, maybe they don't. For the time being, I rather have IsThere/NotThere, than a single IsTh. (2) 100% Undebated Point! I completely missed that one. (3) This might be different in VBA. (4) VBA doesn't have a trim$ (IIRC) (5) Well... No type safety in VBA. You get the oddest variants from the weirdest places. They have default value coercion - so that empty string might actually be an object that suddenly is no more after you said rowset.MoveNext. Anytime I do VBA, I'm tracking the VARTYPEs in my head I think the biggest difference is: You can write a serious application in VB - it's painful, but not impossible with some discipline - exactly what you miss in above code. When you do VBA you are either a "maybe" programmer, struggling with all that fancy programming - for such a guy it's good code (trust me). Or you are a well-rounded programmer stuck with a shit job you want to get over with. While I normally subscribe to "No matter how bad you are on a job, do it as good as you possibly can!" there are some exceptions. VBA is one of them: You don't want to become the VBA expert.


                      We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                      Linkify! || Fold With Us! || sighist

                      J 1 Reply Last reply
                      0
                      • P peterchen

                        (1) Kids program that way. Jumping though hoops to save three letters. I don't really care. Maybe they grow up, maybe they don't. For the time being, I rather have IsThere/NotThere, than a single IsTh. (2) 100% Undebated Point! I completely missed that one. (3) This might be different in VBA. (4) VBA doesn't have a trim$ (IIRC) (5) Well... No type safety in VBA. You get the oddest variants from the weirdest places. They have default value coercion - so that empty string might actually be an object that suddenly is no more after you said rowset.MoveNext. Anytime I do VBA, I'm tracking the VARTYPEs in my head I think the biggest difference is: You can write a serious application in VB - it's painful, but not impossible with some discipline - exactly what you miss in above code. When you do VBA you are either a "maybe" programmer, struggling with all that fancy programming - for such a guy it's good code (trust me). Or you are a well-rounded programmer stuck with a shit job you want to get over with. While I normally subscribe to "No matter how bad you are on a job, do it as good as you possibly can!" there are some exceptions. VBA is one of them: You don't want to become the VBA expert.


                        We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                        Linkify! || Fold With Us! || sighist

                        J Offline
                        J Offline
                        Jeremy Falcon
                        wrote on last edited by
                        #11

                        Well, I don't use VBA and it's on purpose. :laugh: So, I'd have to look up some of these things for VBA, but I really can't imagine how it would be that much different seeing the engine is the same practically. Anyway, I can't agree with your first (counter)point because I believe code should not be ambiguous and always have a single point of execution. Yeah, this is a simple example of it, but not keeping those two things in check make learning a new system that's complex a real PITA later on (or even if you haven't touched the project in years and forgot most of it). If I have two routines serving the same exact purpose, one of them would get wiped, no matter if I had to type three more characters or not IMO.

                        Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                        P 1 Reply Last reply
                        0
                        • J Jeremy Falcon

                          Well, I don't use VBA and it's on purpose. :laugh: So, I'd have to look up some of these things for VBA, but I really can't imagine how it would be that much different seeing the engine is the same practically. Anyway, I can't agree with your first (counter)point because I believe code should not be ambiguous and always have a single point of execution. Yeah, this is a simple example of it, but not keeping those two things in check make learning a new system that's complex a real PITA later on (or even if you haven't touched the project in years and forgot most of it). If I have two routines serving the same exact purpose, one of them would get wiped, no matter if I had to type three more characters or not IMO.

                          Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                          P Offline
                          P Offline
                          peterchen
                          wrote on last edited by
                          #12

                          Jeremy Falcon wrote:

                          the engine is the same practically

                          I'm not sure about that. After all, there are three VB dialects (VBScript, VBA, VB) out there, with ever so subtle differences that I would hazard a guess they are sparate implementations. I've worked a lot with coders on different skill levels, and I learnt to concentrate on the "big" issues. Like Copy & Paste Prgramming, SQL injection, trusting user input, missing borderline cases, etc.


                          We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                          Linkify! || Fold With Us! || sighist

                          J 1 Reply Last reply
                          0
                          • P peterchen

                            Jeremy Falcon wrote:

                            the engine is the same practically

                            I'm not sure about that. After all, there are three VB dialects (VBScript, VBA, VB) out there, with ever so subtle differences that I would hazard a guess they are sparate implementations. I've worked a lot with coders on different skill levels, and I learnt to concentrate on the "big" issues. Like Copy & Paste Prgramming, SQL injection, trusting user input, missing borderline cases, etc.


                            We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                            Linkify! || Fold With Us! || sighist

                            J Offline
                            J Offline
                            Jeremy Falcon
                            wrote on last edited by
                            #13

                            peterchen wrote:

                            I'm not sure about that.

                            You could be right. And, I'd look it up, but I'm heeding your word and making sure I don't become a VBA expert. :->

                            peterchen wrote:

                            I've worked a lot with coders on different skill levels, and I learnt to concentrate on the "big" issues. Like Copy & Paste Prgramming, SQL injection, trusting user input, missing borderline cases, etc.

                            I tend to focus on both. A bunch of little issues left unchecked can lead up to big issues that can't be solved because nobody knows what's going on.

                            Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                            1 Reply Last reply
                            0
                            • N nullGumby

                              Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #14

                              My only question is: Why are you StillThere? ;P Marc

                              Thyme In The Country

                              People are just notoriously impossible. --DavidCrow
                              There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
                              People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

                              1 Reply Last reply
                              0
                              • N nullGumby

                                Every once in awhile someone will ask me to add something to their Access database they've been pouring macro code into for years... So then I have to debug through stuff like this: Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function Public Function NotThere(what As Variant) As Boolean If IsNull(what) Or Trim(what) = "" Or IsEmpty(what) Then NotThere = True Else NotThere = False End If End Function I mean wtf. :mad:

                                L Offline
                                L Offline
                                Luis Alonso Ramos
                                wrote on last edited by
                                #15

                                nullGumby wrote:

                                Public Function IsThere(what As Variant) As Boolean IsThere = Not NotThere(what) End Function

                                Wow! The smartest implementation! :laugh:

                                Luis Alonso Ramos Intelectix Chihuahua, Mexico

                                Not much here: My CP Blog!

                                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