skrr/codingquizzes — pull request #1 by darius (2013-10-30 11:40:09+00:00)
Title: Code review

I liked the testing and the show() method in particular -- very handy in seeing what's going on.

notes.text has my journey of understanding and the most important suggestions. The other commits are generally small coding tips, worth learning but not a big deal individually. The major point is how to think about a data structure with explicit representation and invariants. I think it'd be worthwhile to work out my last question in notes.text -- simplifying the code by eliminating self.gap_buffer.

Not as important, but worth mentioning, is that the class isn't really complete -- it kind of needs methods to retrieve a character or a slice of the text, by position (since calling .save() to convert the whole thing to a string, each time, would defeat the design for efficiency), plus a method to get the cursor position -- that is, at what index in the text will changes be made if you insert or delete right now.

Finally, I'd edit the doc comment to be more like the one I came up with in notes.text. I didn't bother to since it'd be kind of redundant for a code review.