Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistencies & lies in linked list problem #36

Open
Flambino opened this issue Nov 9, 2014 · 8 comments
Open

Inconsistencies & lies in linked list problem #36

Flambino opened this issue Nov 9, 2014 · 8 comments

Comments

@Flambino
Copy link

Flambino commented Nov 9, 2014

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.

@kytrinyx
Copy link
Member

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.

@Flambino
Copy link
Author

Roger that - I'll give it a look tomorrow

@Flambino
Copy link
Author

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 as shiftNode.
  • "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/popNode anyway.
  • deleteNode should 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.

@kytrinyx
Copy link
Member

@wilmoore, @Zandrr -- would you weigh in here?

@kytrinyx
Copy link
Member

ping @wilmoore @Zandrr

@wilmoore
Copy link

@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.

@Flambino
Copy link
Author

@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.

@kytrinyx
Copy link
Member

From earlier:

I'd simply remove those tests

I think that's probably fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants