CodeSOD: Just One Check

This post was originally published on this site

The Daily WTF

Christian works on an application that has some unusual conventions. For example, while I’ve seen many a codebase that Hungarians their private member variables like _myPrivateMember, his team did the opposite: myPrivateMember_.

Someone on the team had a problem: they needed to verify that at least one checkbox was checked. This was their solution to that, in C#:

private void CheckBox_func_member_CheckedChanged(object sender, System.EventArgs e) { if (((PVCheckBox)sender).Checked) { onechecked_ = true; } else { string from = ((CheckBox)sender).Name; if ((from.Equals(“MEMBER”) && !CheckBox_func.Checked) || (from.Equals(“FUNCTION”) && !CheckBox_member.Checked)) { onechecked_ = false; } } }

The first thing I notice is that their checkbox type is PVCheckBox. That’s not the built-in .NET type, which implies that they extended it (or worse, rolled their own). Curiously, the only other place where PVCheckBox appears on the Internet is in a Java library for algorithmic music. Make of that what you will.

So, we

To read the full article click on the 'post' link at the top.