C++: Debugging Linked Lists using Invariants

Channel:
Subscribers:
2,650
Published on ● Video Link: https://www.youtube.com/watch?v=-DCtgAneTEc



Duration: 57:22
99 views
3


Class Invariants aren't just rules for your class that must always be true (though they are that), they are very useful guides when you're writing or debugging code. You can ask yourself, for each invariant, if you're preserving it correctly, and a lot of the time you'll be like oh, wait, yeah, I forgot that one and fix your code even before you begin testing it.

Today we looked at some student code for push_front and pop_back in a singly linked list, and talked about the various problems with it. Learning through debugging is different than from just watching someone solve the problem directly, but is still very useful.