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. Better efficiency?

Better efficiency?

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasequestioncode-review
9 Posts 5 Posters 11 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
    scott_hackett
    wrote on last edited by
    #1

    I once worked with a guy who was writing a lot of the DAL code. When it was time to code review some of his stuff, we saw a lot of functions that made a query string, got a DataSet back, extracted the data from the DataSet and returned the extracted data. Basic stuff. However, there were no DataSets declared locally in any of those functions. He had declared a private DataSet class member and used that in all of those functions. The reason... it was too inefficient to declare them locally when you could do it once at the top of the class! Forehead slaps broke out around the room.

    P V V 3 Replies Last reply
    0
    • S scott_hackett

      I once worked with a guy who was writing a lot of the DAL code. When it was time to code review some of his stuff, we saw a lot of functions that made a query string, got a DataSet back, extracted the data from the DataSet and returned the extracted data. Basic stuff. However, there were no DataSets declared locally in any of those functions. He had declared a private DataSet class member and used that in all of those functions. The reason... it was too inefficient to declare them locally when you could do it once at the top of the class! Forehead slaps broke out around the room.

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

      Sounds like he didn't need a DataSet at all; just a DataTable or a Collection of some Type populated with a DataReader. I very rarely use a DataSet. It seems to me that the power of the DataSet is its ability to contain relationships between the DataTables it contains; so if I don't need those relationships, I don't need a DataSet. If you only need one DataTable, why construct a whole DataSet?

      S L 2 Replies Last reply
      0
      • P PIEBALDconsult

        Sounds like he didn't need a DataSet at all; just a DataTable or a Collection of some Type populated with a DataReader. I very rarely use a DataSet. It seems to me that the power of the DataSet is its ability to contain relationships between the DataTables it contains; so if I don't need those relationships, I don't need a DataSet. If you only need one DataTable, why construct a whole DataSet?

        S Offline
        S Offline
        scott_hackett
        wrote on last edited by
        #3

        It wasn't that he was or wasn't using a DataSet... he was using the same DataSet member variable for all of the queries run in the class. It's like declaring a class member variable i for all of the for loops that you're going to do in your class.

        P 1 Reply Last reply
        0
        • S scott_hackett

          I once worked with a guy who was writing a lot of the DAL code. When it was time to code review some of his stuff, we saw a lot of functions that made a query string, got a DataSet back, extracted the data from the DataSet and returned the extracted data. Basic stuff. However, there were no DataSets declared locally in any of those functions. He had declared a private DataSet class member and used that in all of those functions. The reason... it was too inefficient to declare them locally when you could do it once at the top of the class! Forehead slaps broke out around the room.

          V Offline
          V Offline
          Vasudevan Deepak Kumar
          wrote on last edited by
          #4

          Was he in a way reinventing the wheel?

          Vasudevan Deepak Kumar Personal Homepage Tech Gossips

          S 1 Reply Last reply
          0
          • P PIEBALDconsult

            Sounds like he didn't need a DataSet at all; just a DataTable or a Collection of some Type populated with a DataReader. I very rarely use a DataSet. It seems to me that the power of the DataSet is its ability to contain relationships between the DataTables it contains; so if I don't need those relationships, I don't need a DataSet. If you only need one DataTable, why construct a whole DataSet?

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

            PIEBALDconsult wrote:

            Sounds like he didn't need a DataSet at all

            :omg::~

            led mike

            1 Reply Last reply
            0
            • V Vasudevan Deepak Kumar

              Was he in a way reinventing the wheel?

              Vasudevan Deepak Kumar Personal Homepage Tech Gossips

              S Offline
              S Offline
              scott_hackett
              wrote on last edited by
              #6

              Is that a serious post... for real? I now return to The daily WTF for all of my coding freak out needs.

              V 1 Reply Last reply
              0
              • S scott_hackett

                It wasn't that he was or wasn't using a DataSet... he was using the same DataSet member variable for all of the queries run in the class. It's like declaring a class member variable i for all of the for loops that you're going to do in your class.

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

                Yes, I understand that, but if he was concerned about the footprint and/or construction time of a DataSet, why create any at all?

                1 Reply Last reply
                0
                • S scott_hackett

                  I once worked with a guy who was writing a lot of the DAL code. When it was time to code review some of his stuff, we saw a lot of functions that made a query string, got a DataSet back, extracted the data from the DataSet and returned the extracted data. Basic stuff. However, there were no DataSets declared locally in any of those functions. He had declared a private DataSet class member and used that in all of those functions. The reason... it was too inefficient to declare them locally when you could do it once at the top of the class! Forehead slaps broke out around the room.

                  V Offline
                  V Offline
                  Virtual Coder
                  wrote on last edited by
                  #8

                  scott_hackett wrote:

                  He had declared a private DataSet class member and used that in all of those functions. The reason... it was too inefficient to declare them locally when you could do it once at the top of the class!

                  This clearly is a 'code smell'. The state of an object should not be littered with local states. This kind of private members often need to be reset when the function starts - a constant source for bugs. Most probably not even the claimed spreed improvement is true.

                  1 Reply Last reply
                  0
                  • S scott_hackett

                    Is that a serious post... for real? I now return to The daily WTF for all of my coding freak out needs.

                    V Offline
                    V Offline
                    Vasudevan Deepak Kumar
                    wrote on last edited by
                    #9

                    scott_hackett wrote:

                    Is that a serious post... for real?

                    Couldn't get you?

                    Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                    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