Present it chunk by chunk? Makes it a pain in the ass to type in, or copy'n'paste from Safari (which, being in a country far far away from my ORA book collection, I have grown to love).
Present the whole program and then talk about it? Do you reproduce the fragments you're talking about? Number lines? (Line numbering loses you valuable columns for code, and anyone who has ever line-broken code for publication knows what a precious resource they are). Bold lines of code in the initial presentation?
So many decisions! Can you remember a book with large code examples where the discussion of the code examples was easy to follow? Tell me how they did it! If you can only remember books where it didn't work, still tell me!
Thanks,
--Nat
comments (Score:1)
hmm... I probably should have been more helpful
gav
please no long blocks of code (Score:2)
long blocks of code sucks. Even if it's to show something cool. I always just skip over long pages of code and just read the discussion of it; referring back to the code if I have to. I don't always get a lot of out of that, go figure.
If it's to demostrate a concept; then show the concept with text and diagrams. If it's to show cool code; well, maybe it isn't so cool if it takes several pages to explain.
In other words: I prefer the "in smaller chunk" approach. Maybe I have happily read long snippets o
-- ask bjoern hansen [askbjoernhansen.com], !try; do();
Re:please no long blocks of code (Score:2, Interesting)
what about both? (Score:2, Informative)
Presentation (Score:1)
For presentations I tend to rewrite the code to just have the bits I care about (removing half the error checking, renaming variables to be shorter, putting in elipsis here and there), then make sure the whole example fits on one screen. Then I decide which bits I want to talk about, and provide a series of slides with the important bits highlighted in red as I talk about them. If I'm going to be entirely sequential then I'll start with all the code grey, and turn it black as I talk about it.
like Programming Python (Score:1)
just do the entire book (Score:2)
In courier :)
Brevity is what I look for in code samples...shit that goes on for pages means I'm going to have to flip pages and right there, I'm not interested. I liked the perl cookbook with little chunks and small lessons building up to a full program at the end.
Concise, Illustrative, Correct code.
In smallish chunks but... (Score:2, Insightful)
When each method is short and does one thing, or does more than one thing by delegating to other well named methods, it's relatively easy to discuss a method in isolation. Also, short methods tend not to involve deep indentation, which is a big win in a book.
Why do I get the feeling that this is o
Another example (Score:2, Interesting)
Long code block (Score:2, Informative)
Programming topics don't lend themselves to long, wordy explanations. There's no point to it. I can't think of a programming discussion that lends itself to that kind of explanation without a diagram or a piece of pseudocode somewhere
Petzold -- Look at his books (Score:2, Insightful)
1. First lots of white space
2. The code is well factored.
a. It is broken down into subcomponents
b. It builds of previously explained code.
c. He shows you six different ways to do the same thing(like create a window), but when you are done, you know all of the ways to do it.
True his books are 1,000+ pages, and are designed so that you type all of the code in, but I per
Make each program different (Score:2, Insightful)
Re:Make each program different (Score:2)
-- ask bjoern hansen [askbjoernhansen.com], !try; do();