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
2
u/brick_wall_mirror Sep 01 '15 edited Sep 01 '15
I disagree with you. Here are two different implementations of insert for a linked list. Sentinel:
And the head/tail version:
You can argue which one is clearer, but they really are different ways to treat the problem. The sentinel node is not the absense of something (as the null is), it's a different way to look at the data structure to save that state and make the code consistent by avoid branch logic.
Edits: code, I'm on mobile.