Curious Perversions in Information Technology
7k followers 5 cikk/hét
CodeSOD: Delectable Code

Good method names are one of the primary ways to write self-documenting code. The challenge there, is that documentation often becomes out of date. Take this delectable PHP nugget, from Nathaniel P, who has previously been tortured by bad date handling. function deleteTenDays() { //This delects everything from the table minus 3 days ...

Mon May 20, 2024 14:18
Error'd: ABQ is the bomb

This week we have an unusual number of submissions involving dates or timestamps. That is, the usual sorts of error'ds, but unusually many of them. Gerald E. chuckled "I do love the back to the future movies. But now I can see Beck from the future."   Steven J. Pemberton , as his mother calls him, snarked about Utilita: "I received...

Fri May 17, 2024 13:59
CodeSOD: Scoring the Concatenation

Today's a simple one. We've all seen code that relies too heavily on string concatenation and eschews useful methods like Join. Nick L sends us this VB.Net example, written by a slew of mechanical engineers. PartSearchDescription = _ dFrameType + _ dFrameSize + _ dSYZD + _ dPoles + _ dBearingType + _ dBearingInsulated...

Thu May 16, 2024 15:08
CodeSOD: A Poorly Pruned Branch

Juliano had this very non-WTF bit of PHP code: if (!$path) { //do stuff } else { //do other stuff } After another team member made a commit, however, the code turned into this: if (1 == 2) { //do stuff } else { //do other stuff } Now, generally, when I see 1 == 2 type expressions, I just assume that this is a templated, generated...

Wed May 15, 2024 14:17
CodeSOD: Many Unhappy Returns

Gavin continues work on the old C++ app he inherited. Today we get a delightful smattering of bad choices. HRESULT CExAPI::GetPageCacheForFolder( IN CEntryID *p_cio_Folder, OUT CPageCache **pp_PC ) { CEntryID *p_cio_Local = new CEntryID( this, p_cio_Folder ); switch ( p_cio_Folder->m_uiType ) { case EID_TYPE_EMPTY: return S_OK;...

Tue May 14, 2024 14:23
CodeSOD: Accessed Nulls

"The attached class connects to an Access database," writes Nicolai. That's always a good start for a WTF. Let's take a look. public class ResultLoader { private static Logger sysLog = Logger.getLogger(ResultLoader.class); private static String url = "somePath"; /** * get the ResultTable from the Access database * * @param tableName...

Mon May 13, 2024 15:13

Készítse el saját hírfolyamát

Készen áll, hogy kipróbálja?
Indítson egy 14 napos próbaverziót, ehhez nincs szüksége bankártyára.

Fiók létrehozása