- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Office Politics
- Secret Horror
- Not Impossible
- Monkeys
- Killing Time
- Hypersensitive
- Infallabella
- Doubled Daniel
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
[pre]private static boolean existsFirstPost(ArrayList<Integer> postFolder, Integer postId) { for (Integer post : postFolder) { if (post.equals(postId)) return true; } return false; } [/pre]
Admin
The developer had family issues - daddy wasn't around.
Admin
Yeah, of course he didn't know, because clearly no collections library ever has methods like C++'s
std::map<...>::find(...)
.Or maybe that's the problem. He looked for a method called
find
, but couldn't ... er ... find ... it.Admin
this some implementation of a hierarchical(?) structure, which determines if an element is contained in an (arbitrary) object called father-folder?
Admin
A static method for this, and a list of fathers, not children, really reeks of whatever design they have being utterly harebrained.
I'd almost like to see the whole tree-handling code, even though I know I'd lose IQ points by having seen it.
Admin
Perhaps it's a graph rather than a tree, which would explain why a node can have several fathers.
Admin
I'm guessing it's a list of all parents going up the tree, so it's just a single path up the tree, rather than the full tree. The integers would be IDs. Why? From where? I can't answer that.
Answers, much like the code writer's father, left for milk a long time ago.
Admin
As a father of 2, I sometimes wonder if I'm who I think I am. Maybe I could use this function in my life? Or maybe this is a test for the old song "I'm My Own Grandpa"?
Admin
Never trust the framework! Always reimplement basic functions like that, it's the only way to trust your code!
NIH rocks.
PS: such a short method obviously is perfect and doesn't need unit tests. It's so simple, there's no way it could fail. Unit tests are for weaklings who write bugs anyway.
Admin
errm, to the best of my knowledge there's no Java builtin for trees, either you use TreeItem (from JavaFx, watch out for memory leaks) or make your own tree data structure, perhaps there is some library around, don't know, long speech cut short, use a parent member in your data structure
Admin
You're correct — Java has collection classes backed by B-tree structures (TreeMap, TreeSet), but there's no general-purpose implementation hierarchical data structure... probably because such things tend to be more specialised use cases where an out-of-the-box option probably won't make anybody happy.
Edit Admin
Facts not in evidence. I don't see any evidence from that code of any kind of tree structure.
Admin
"existsFather(ArrayList<Integer> fatherFolder, Integer fatherId)"? Sexist pig.
Edit Admin
C# is now killing Java development