Inconsistencies & lies in linked list problem
Overall, there's the question of whether this problem is about a linked list implementation or (more specifically) a deque implementation based on a doubly-link list. The problem is mixing the two terms a little willy-nilly.
But somewhat more worrisome: The first test is for a property named count (specifically that it's zero for an empty deque). But there are also tests for a countNodes() function. Either one would make sense on its own, but having both is strange, IMO. The function implies implementing something that walks the list, while the property implies that the deque's length should be tracked "manually".
(Okay, you could implement a dynamic count property using Object.defineProperty, or just return the property in countNodes, but the former that seems out-of-scope for the task, and the latter seems very redundant.)
And then there's this:
To keep your implementation simple, the tests will not cover error conditions. Specifically: pop or shift will never be called on an empty Deque.
Lies! There's a test specifically for that, actually.
The tests also seem to follow a different style than others: It's got 4 spaces of indentation, and could use some blank lines to breathe. The file you have to create is also (so far) the only camelCased filename I've come across, which made me raise an eyebrow - but I won't claim that's necessarily wrong. Just weird.
All in all, it just seems kinda messy.
I'd be happy to fix the stuff (don't know about the file name) - just let me know.
Consistency and correctness would be very nice, and I would welcome a pull request that fixes these things.
The README (in the exercism/x-common repository) might be a special case of just removing the bit about what will or will not be tested, since this problem varies from language to language.
Roger that - I'll give it a look tomorrow
I'm looking over the tests, and I've got a question: Is a deleteNode function actually called for? The tests of it are confusing (see below), and besides, the readme (nor a classic deque implementation) doesn't require any such functionality.
I'd simply remove those tests, but I figured I'd ask first, since it changes the problem.
As for the tests being weird:
- "deletes last element from list" actually deletes the first of three nodes. So it sounds like it's supposed to basically do the same as
popNode, but instead it does the same asshiftNode. - "deletes only the last element" adds a single node, and then deletes it. I've no idea what that proves, and it's the same as
shiftNode/popNodeanyway. deleteNodeshould apparently find nodes by their value, but from the tests it's unclear if it should delete all matching nodes, just the first one, or just the last one.
@wilmoore, @Zandrr -- would you weigh in here?
ping @wilmoore @Zandrr
@Flambino, @Zandrr, and @kytrinyx,
It would be great to clean up this assignment and make it conform more to a basic linked-list implementation.
I'd prefer to see the tests re-written to confirm to the simple implementation.
@kytrinyx, @wilmoore and @Zandrr,
well, I promised I'd take a look at it, and so I shall. I should've done so weeks ago, but got sidetracked. But I'll give a once-over one of the coming days.
From earlier:
I'd simply remove those tests
I think that's probably fine.