Better efficiency?
-
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.
-
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.
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?
-
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?
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. -
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.
Was he in a way reinventing the wheel?
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
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?
-
Was he in a way reinventing the wheel?
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
Is that a serious post... for real? I now return to The daily WTF for all of my coding freak out needs.
-
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.Yes, I understand that, but if he was concerned about the footprint and/or construction time of a DataSet, why create any at all?
-
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.
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.
-
Is that a serious post... for real? I now return to The daily WTF for all of my coding freak out needs.
scott_hackett wrote:
Is that a serious post... for real?
Couldn't get you?
Vasudevan Deepak Kumar Personal Homepage Tech Gossips