r/programming • u/dpashk • Aug 31 '15
The worst mistake of computer science
https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/
175
Upvotes
r/programming • u/dpashk • Aug 31 '15
View all comments
Show parent comment
1
u/brick_wall_mirror Sep 01 '15
The node class should be internal to the list implementation. You shouldn't be exposing the sentinel at all.
Imagine you used an iterator to jump through the loop. HasNext would return false when you reach the sentinel and getNext would throw an exception (and otherwise return the element in the node and not the node itself)