· 00:58
Welcome to The Daily WTF Podcast, where we delve into the quirks of coding gone wrong. Today, we take a look at a code snippet that highlights the struggles of object-oriented programming. The code in question is designed to convert a string into an appropriate data type, but it complicates rather than simplifies the process.
“As the article points out, ‘This takes a string and then tries to parse it, first into a boolean, failing that into an integer, and failing that into a double.’” The result? You end up with an object that leaves you guessing about its type. This leads to risky casting, like so: “boolean myBoolField = (Boolean)createValue(someStringContainingABool);”
It’s no wonder Gary, who discovered this code in a long-abandoned project, remarked, “I can’t imagine why it ended up getting abandoned.” This should serve as a cautionary tale about the dangers of stringly typed data.
Join us next time for more coding blunders and lessons learned!
Link to Article
Listen to jawbreaker.io using one of many popular podcasting apps or directories.