Chapter 12. Adding the Section Tag, Part II
We’ll continue refactoring our TextModel. Stand back, I don’t know how good this thing gets!
Reviewing the Code
The TextModel.cs file was posted at the end of Chapter 11. We can still see lots of duplication in that code. There seems to be a general confusion between whether we want the lines to be an Array or an ArrayList, for example. That should be cleaned up. And here are two methods that are clearly duplication and that I think we should go after:
public void InsertParagraphTag() { if ( lines.Count == 0 ) { lines.Add( "<P></P>" ); selectionStart = 3; return; } lines.InsertRange(LineContainingCursor()+1, NewParagraph()); selectionStart = NewSelectionStart(LineContainingCursor() + 2, "<P>"); } public ...
Get Extreme Programming Adventures in C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.