The Daily WTF
Follow
CodeSOD: Currency Format
Dark Horse's PHP code demonstrates poor coding practices, with repetitive code to format object fields. The object contains a vast number of fields named in a complex pattern, including currency-specific fields.The code dynamically constructs field names using a variable, which is considered poor practice. Instead of looping over the numeric fields, the code uses separate lines for each field.The currency values are not organized in an array, making it difficult to work with them efficiently. The code lacks cohesion and could be significantly improved by refactoring and using more appropriate data structures.The code's naming convention is also confusing, with field names that lack clarity and context. The choice of object-oriented programming seems inappropriate given the simple task at hand.Overall, the code is unnecessarily verbose, inefficient, and difficult to maintain.