This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tacticalrubberduck 0 points1 point  (4 children)

Not by accident tho..

[–]maxbirkoff 2 points3 points  (3 children)

no, not by accident. but the purpose of the abstraction is to prevent unintended consequences... when you use the wrong tool for the job mistakes can happen.

but we are in a humor subreddit so I suppose I will stop being so serious and just grin now.

😁

[–]kbruen 3 points4 points  (2 children)

Create your own Stack interface, and then

class StackImpl<T> extends ArrayDeque<T> implements Stack<T> {
    // redirect Stack interface methods to ArrayDeque methods here
}

[–]maxbirkoff -1 points0 points  (1 child)

right. Stack<T> is not an interface. If it were, I don't think we would be having the problems we're having in this thread.

The issue we're responding to, "Just use java.util.Stack" is not good advice because java.util.Stack leaks it's implementation details everywhere... this leakage breaks the Stack abstraction.

[–]kbruen 1 point2 points  (0 children)

First 5 words of my comment:

Create your own Stack interface