CodeSOD: Delete Column From List
by Remy Porter from The Daily WTF on (#5RQX7)
Anastacio knew of a programmer at his company by reputation only- and it wasn't a good reputation. In fact, it was bad enough that when this programmer was fired, no one- even people who hadn't met them- was surprised.
The firing wasn't all good news, though. That code needed to be maintained, and someone had to do it. That's how Anastacio suddenly owned 50,000 lines of code written by his predecessor. It didn't take long to see that this didn't need to be anything like 50,000 lines long, though.
For example:
//how to remove the columns of a list with aggressive optimizations enabledlist.DeleteColumn(61);list.DeleteColumn(60);list.DeleteColumn(59);list.DeleteColumn(58);list.DeleteColumn(57);list.DeleteColumn(56);list.DeleteColumn(55);list.DeleteColumn(54);list.DeleteColumn(53);list.DeleteColumn(52);list.DeleteColumn(51);list.DeleteColumn(50);list.DeleteColumn(49);list.DeleteColumn(48);list.DeleteColumn(47);list.DeleteColumn(46);list.DeleteColumn(45);list.DeleteColumn(44);list.DeleteColumn(43);list.DeleteColumn(42);list.DeleteColumn(41);list.DeleteColumn(40);list.DeleteColumn(39);list.DeleteColumn(38);list.DeleteColumn(37);list.DeleteColumn(36);list.DeleteColumn(35);list.DeleteColumn(34);list.DeleteColumn(33);list.DeleteColumn(32);list.DeleteColumn(31);list.DeleteColumn(30);list.DeleteColumn(29);list.DeleteColumn(28);list.DeleteColumn(27);list.DeleteColumn(26);list.DeleteColumn(25);list.DeleteColumn(24);list.DeleteColumn(23);list.DeleteColumn(22);list.DeleteColumn(21);list.DeleteColumn(20);list.DeleteColumn(19);list.DeleteColumn(18);list.DeleteColumn(17);list.DeleteColumn(16);list.DeleteColumn(15);list.DeleteColumn(14);list.DeleteColumn(13);list.DeleteColumn(12);list.DeleteColumn(11);list.DeleteColumn(10);list.DeleteColumn(9);list.DeleteColumn(8);list.DeleteColumn(7);list.DeleteColumn(6);list.DeleteColumn(5);list.DeleteColumn(4);list.DeleteColumn(3);list.DeleteColumn(2);list.DeleteColumn(1);list.DeleteColumn(0);
Anastacio is optimistic:
[Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!Given a few weeks, I will be able to shrink it to less than 10,000 [lines].