I’m glad I tested this one on some scrap yarn before doing it on my project: I want to put in a purl stripe of 4 rows, but in a different color. http://www.bloomoon.com/b4.html
But I wasn’t sure if I should change color on the same row as the stitch pattern change or not, so I tested it, and found it worked best as follows: When changing from knit to purl (as seen from the right side), change color on the row before changing to purl. When changing back from purl to knit, change color and stitch pattern in the same row.