That's What I Want
by in Error'd on 2026-03-06
First up with the money quote, Peter G. remarks "Hi first_name euro euro euro, look how professional our marketing services are! "
First up with the money quote, Peter G. remarks "Hi first_name euro euro euro, look how professional our marketing services are! "
We mostly don't pick on bad SQL queries here, because mostly the query optimizer is going to fix whatever is wrong, and the sad reality is that databases are hard to change once they're running; especially legacy databases. But sometimes the code is just so hamster-bowling-backwards that it's worth looking into.
Jim J has been working on a codebase for about 18 months. It's a big, sprawling, messy project, and it has code like this:
Today's snippet from Rich D is short and sweet, and admittedly, not the most TFs of WTFs out there. But it made me chuckle, and sometimes that's all we need. This Java snippet shows us how to delete a file:
if (Files.exists(filePath)) {
Files.deleteIfExists(filePath);
}
Agatha has inherited some Windows Forms code. This particular batch of such code falls into that delightful category of code that's wrong in multiple ways, multiple times. The task here is to disable a few panels worth of controls, based on a condition. Or, since this is in Spanish, "bloquear controles". Let's see how they did it.
private void BloquearControles()
{
bool bolBloquear = SomeConditionTM; // SomeConditionTM = a bunch of stuff. Replaced for clarity.
// Some code. Removed for clarity.
// private System.Windows.Forms.Panel pnlPrincipal;
foreach (Control C in this.pnlPrincipal.Controls)
{
if (C.GetType() == typeof(System.Windows.Forms.TextBox))
{
C.Enabled = bolBloquear;
}
if (C.GetType() == typeof(System.Windows.Forms.ComboBox))
{
C.Enabled = bolBloquear;
}
if (C.GetType() == typeof(System.Windows.Forms.CheckBox))
{
C.Enabled = bolBloquear;
}
if (C.GetType() == typeof(System.Windows.Forms.DateTimePicker))
{
C.Enabled = bolBloquear;
}
if (C.GetType() == typeof(System.Windows.Forms.NumericUpDown))
{
C.Enabled = bolBloquear;
}
}
// private System.Windows.Forms.GroupBox grpProveedor;
foreach (Control C1 in this.grpProveedor.Controls)
{
if (C1.GetType() == typeof(System.Windows.Forms.TextBox))
{
C1.Enabled = bolBloquear;
}
if (C1.GetType() == typeof(System.Windows.Forms.ComboBox))
{
C1.Enabled = bolBloquear;
}
if (C1.GetType() == typeof(System.Windows.Forms.CheckBox))
{
C1.Enabled = bolBloquear;
}
if (C1.GetType() == typeof(System.Windows.Forms.DateTimePicker))
{
C1.Enabled = bolBloquear;
}
if (C1.GetType() == typeof(System.Windows.Forms.NumericUpDown))
{
C1.Enabled = bolBloquear;
}
}
// private System.Windows.Forms.GroupBox grpDescuentoGeneral;
foreach (Control C2 in this.grpDescuentoGeneral.Controls)
{
if (C2.GetType() == typeof(System.Windows.Forms.TextBox))
{
C2.Enabled = bolBloquear;
}
if (C2.GetType() == typeof(System.Windows.Forms.ComboBox))
{
C2.Enabled = bolBloquear;
}
if (C2.GetType() == typeof(System.Windows.Forms.CheckBox))
{
C2.Enabled = bolBloquear;
}
if (C2.GetType() == typeof(System.Windows.Forms.DateTimePicker))
{
C2.Enabled = bolBloquear;
}
if (C2.GetType() == typeof(System.Windows.Forms.NumericUpDown))
{
C2.Enabled = bolBloquear;
}
}
// Some more code. Removed for clarity.
}
Python is (in)famous for its "batteries included" approach to a standard library, but it's not that notable that it has plenty of standard data structures, like dicts. Nor is in surprising that dicts have all sorts of useful methods, like pop, which removes a key from the dict and returns its value.
Because you're here, reading this site, you'll also be unsurprised that this doesn't stop developers from re-implementing that built-in function, badly. Karen sends us this: