Monday, December 22, 2014

What's Up with Java Linked List? Is this Foreign Engineering?

Usually I like my foreign engineering my Honda and Porsches. But when it comes to code, YUK! The spelling errors and Homonyms are sometimes quite terrible.

So when I came across this in the LinkedList spec for Java well, it was frightening. I can just picture the conversation:

Java Architect : "And be sure to add a PULL method, with PullFirst and PullLast as well, to remove the elements"

Foreign Java Engineer : "OK sure no problem, I will add the Poll Methods"

OKOK not to pic on foreign engineers. It appears that the problem is pretty endemic to the Collections framework. So what gives? I've been around enough to know anachronisms like SPOOL and suchnots. So where did this come from anyone have a clue?

The thing is semantically POLL makes no sense as a modifying method. To take a poll is like taking a temperature it is just a measure, it would just return the result never modify. So this is just horrific coding that's creeped into the Java language. I'm sure they spell check it but there are always problems like this where people make semantic errors. Maybe it wasn't a foreign engineer. It's still quite poor. I'm not sure which version this was added but I'd guess it was done post oracle acquisition. I'd yell at my friend Larry but he's already retired.


poll()
Retrieves and removes the head (first element) of this list.
EpollFirst()
Retrieves and removes the first element of this list, or returns null if this list is empty.
EpollLast()
Retrieves and removes the last element of this list, or returns null if this list is empty.

No comments:

Post a Comment