The Daily WTF
Andre has inherited a rather antique ASP .Net WebForms application. It’s a large one, with many pages in it, but they all follow a certain pattern. Let’s see if you can spot it.
protected void btnSearch_Click(object sender, EventArgs e) { ArrayList paramsRel = new ArrayList(); paramsRel[“Name”] = txtNome.Text; paramsRel[“Date”] = txtDate.Text; Session[“paramsRel”] = paramsRel; List<Client> clients = Controller.FindClients(); //Some other code }
Now, at first glance, this doesn’t look terrible. Using an ArrayList as a dictionary and frankly, storing a dictionary in the Session object is weird, but it’s not an automatic red flag. But wait, why is it called paramsRel? They couldn’t be… no, they wouldn’t…
public List<Client> FindClients() { ArrayList paramsRel = (ArrayList)Session[“paramsRel”]; string name = (string)paramsRel[“Name”]; string dateStr = (string)paramsRel[“Date”]; DateTime date = DateTime.Parse(dateStr); //More code… }
Now there’s the red flag. paramsRel is how they pass parameters to functions. They stuff it into the
To read the full article click on the 'post' link at the top.