Get Rid of the Text Copy

Recall that the InsertParagraphTag method makes a copy of lines into newlines with this code:

 newlines = new ArrayList(); 

We should be able to do this edit directly into the lines variable, by using InsertRange instead of AddRange. To make it work completely, however, is a pretty big edit: there might be various places that rely on newlines . So I decided that first I would make the InsertRange work and only then remove newlines . To accomplish that, I wrote this code:

 newlines = new ArrayList(lines); 
newlines.InsertRange(LineContainingCursor()+1, NewParagraph());

That leaves the result in the newlines variable, so this is the only code that has to change to test things. And sure enough, it worked just fine! The next step was just to replace all references to newlines with references to lines . I did a few of those with a quick text find ”where, oh where, is Smalltalk s Browse References ? Then I removed the instance variable newlines , compiled (finding one more reference), and the program still runs all the tests, even the acceptance test that we haven t told you about yet.

Extreme Programming Adventures in C#
Javaв„ў EE 5 Tutorial, The (3rd Edition)
ISBN: 735619492
EAN: 2147483647
Year: 2006
Pages: 291 © 2008-2017.
If you may any questions please contact us: