CodeSOD: Location Chooser
Today's anonymous submitter inherited an application with a huge list of bugs and feature requests for missing features. While tracking down a bug, our submitter learned a lot about why "Allow additional stores to be viewable in the store selector," was an unimplemented feature.
if (inv.inv_storeloc == 0) {out.println("<option selected value=\"0\">Select</option>");out.println("<option value=\"1\">Location 1</option>");out.println("<option value=\"2\">Location 2</option>");} else if (inv.inv_storeloc == 1) {out.println("<option selected value=\"1\">Location 1</option>");out.println("<option value=\"2\">Location 2</option>");} else {out.println("<option value=\"1\">Location 1</option>");out.println("<option selected value=\"2\">Location 2</option>");}
If the user has not selected a store, we will output three options, selecting the first one- a prompt to select a store. If they have selected store 1, we output two options, with store one selected. Otherwise, we output two options with store two selected.
This has a little of everything. No real understanding of how to apply the selected attribute with a loop and conditionals. Hard coded HTML strings in the back end code. Hard coded store names which will be great if our business expands (or contracts).
I suspect the list of missing features isn't going to get much shorter, and the list of bugs is only going to get longer.
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!