O'Reilly logo

Extreme Programming Adventures in C# by Ron Jeffries

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required