Popular burger chain announces shock closure of all UK restaurants after 13 years as fans say it's the 'end of an era'
Live: Traffic chaos for drivers on A12 during rush hour after crash
This Morning's Eva Speakman is forced to defend husband Nik's changing face after cruel trolls criticised his new appearance
Nvidia no longer world's most valuable company after losing $589 BILLION in biggest stock drop in history
Inside Charles and Camilla's 'coming out' party at the Ritz: Following the death of the beloved Princess Diana, the royal couple were steeped in controversy - but on this day 26 years ago they began their public relations comeback with an iconic photo...
Peeing Is Socially Contagious In Chimps
Read more of this story at Slashdot.
Now criticising two-tier policing can be example of 'far-Right extremism', leaked Home Office report claims
Gunfight erupts on the border as Mexican drug cartels smuggling migrants across open fire on US Border Patrol agents
The bold warning to Melania Trump's critics hidden in her new official White House portrait
CodeSOD: Contains Bad Choices
Paul's co-worker needed to manage some data in a tree. To do that, they wrote this Java function:
private static boolean existsFather(ArrayList<Integer> fatherFolder, Integer fatherId) { for (Integer father : fatherFolder) { if (father.equals(fatherId)) return true; } return false; }I do not know what the integers in use represent here. I don't think they're actually representing "folders", despite the variable names in the code. I certainly hope it's not representing files and folders, because that implies they're tossing around file handles in some C-brained approach (but badly, since it implies they've got an open handle for every object).
The core WTF, in my opinion, is this- the code clearly implies some sort of tree structure, the tree contains integers, but they're not using any of the Java structures for handling trees, and implementing this slipshod approach. And even then, this code could be made more generic, as the general process works with any sane Java type.
But there's also the obvious WTF: the java.util.Collection interface, which an ArrayList implements, already handles all of this in its contains method. This entire function could be replaced with fatherFolder.contains(fatherId).
Paul writes: "I guess the last developer didn't know that every implementation of a java.util.Collection has a method called contains. At least they knew how to do a for-each.".