I think defining humour is one of those things which is such a gray area - there's no real cut or dry! For instance, I love Monty Python but I can't stand shows like "The Big Bang Theory", even though they're both "comedies".
In terms of writing for them, it really depends on the talent you're using.
To clarify; think about actors like Will Ferrell, Robin Williams, Steve Carell or Russell Brand.
These guys have basically built a career on taking a guided script, improvising 90% of it and really putting their acting skills to make it funny... If you are working with actors (or have actors in mind) who are known for their improvisation, then you would be doing them a disservice (and probably wasting your time) to go into a detailed line-for-line script which force feeds them words.
Check out some out-takes from Anchor Man (
http://www.youtube.com/watch?v=qGG13xG_zAw) and Date Night (
http://www.youtube.com/watch?v=pu_kHzUSN40) for some examples of how the actors build upon what they have and pass the puck back and forth.
Then, let's jump over to the other side and look at "British" humor. The guys at the Whitest Kids You Know talk about how they improvise the initial idea but then follow everything to the letter. This sort of humour relies more upon the word play ALA Monty Python. Here's an example of "Grapist" (SFW: 9mil + views)
http://www.youtube.com/watch?v=Fqq051BU2MY from WKUK.
That being said - it still needs to play well. I, for instance, hate "The Big Bang Theory" with the passion of a thousand suns simply because of the trite crap they spout, the laughter track which ruins it all and the horrible delivery skills of their characters - it seems more of a "hey here are 100 jokes, let's make some dialogue up to fit them" rather than being the other way around.
SO, to sum it up - there's a lot of different shades of humor and, unfortunately, a lot of it comes down to the sort of film (or short, or episode or even sound clip) that you want to produce and the actors you will be working with. It might help to watch some movies that you enjoy and found to be funny and then try to classify it and determine what sort of motifs or techniques they've used (was it slapstick? Was it wordplay? Was it as bad as Adam Sandler's new movie?) and in particular what
DIDN'T work.
Phew I think I need a cold beer after that =D