The Daily WTF
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 ...
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...
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...
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...
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;...
"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...
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.