The Daily WTF
Follow
CodeSOD: Yes, No, NO NO NO NO
The code defines functions for converting between booleans and a custom "YesNoType" class, which essentially represents a boolean value stored as a string.The "toYesNo(String)" function maps "Y" to "Yes" and other values to "No," introducing potential inconsistency since it always returns "Yes" regardless of the input string.The "toYesNo(boolean)" function cannot directly construct a "YesNoType" from a boolean, which is considered a flaw.The "fromYesNo(YesNoType)" function checks if the "YesNoType" matches "Yes" (case-insensitive) and returns "Yes" accordingly.The "isYesNo(YesNoType)" function converts the "YesNoType" to a boolean, but unnecessarily declares a local variable and could be simplified.The code's reliance on a custom "YesNoType" instead of using booleans is seen as a questionable design choice.The "toYesNo(String)" function allows setting a "YesNoType" with "Y" but always returns "Yes," creating inconsistent values.The "toYesNo(boolean)" function cannot create a "YesNoType" directly from a boolean, a significant drawback.The "fromYesNo(YesNoType)" function seems unnecessary with proper design.Overall, the code's use of "YesNoType" as a string-based representation of booleans is considered a poor design decision.