Just taking an informal survey here - when you see code in a book, would you rather see a couple of pages of code then the explanation for the whole thing or a chunk along with it's explanation? Another possiblity - if the code is a class what would you think about all of the members of the class and their explanation, then the class functions and their explanation. Or some other totally different layout. What works best for you?