The Daily WTF
Follow
CodeSOD: A Dropped Down DataSet
Object-Relational Mapping tools offer benefits like type safety by mapping database relations to programming language types. However, a specific example highlights poor coding practices. The code iterates through a disconnected ADO.NET DataSet, which models database data in memory. Accessing tables by index (e.g., Table(0)) instead of name is inefficient. More significantly, the data retrieval chain is unnecessarily verbose and prone to errors. The code repeatedly calls methods like ToUpper and ToString on data fields. This chain becomes absurd with redundant ToUpper calls for "Tachometer." An exception handler is used for potential null values, not database connection errors. This handler lacks specific exception checking, assuming only nulls cause issues. A table schema change broke the code by altering column indexing, but the handler masked the error. Users experienced broken functionality, like missing "Pump Bracket" entries, without clear error messages. The commented-out message box suggests frequent null errors overwhelmed users.