It feels like everyone agrees to accept what user notes have become 
(everything), so let's dive deeper into each category with this thread being 
about code snippets. Warning: this thread may contain crazy rambling thoughts 
and ideas, but that's okay (today).

A few thoughts that come to mind:
 * Tagged as a code snippet
 * Users rate it, 1-10
 * Ensure the copyright/license stuff is clear
 * Syntax highlighting, and worrying about <?php
 * Dealing with PHP version requirements?
 * One [good] snippet on multiple manual pages?
 * Users comment on individual snippets?
 * Some notes will contain a lot of words with a small code snippet, what tag 
is it?
 * Define what makes a good one (teaches about the topic, secure, concise, ...)
 * Define what makes a bad one (generic, insecure, too long, overly complex, 
...)

Example of good versus bad:
 * A piece of code is well written, about 20 lines, and is about creating a 
password. It happens to use strlen() a couple times so is posted under 
function.strlen. Good? Bad?

A few other questions:
 * Let's say a piece of code is great, voted up, and uses 5 internal PHP 
functions. Should we scan it, then automagically make the snippet linked to the 
5 manual pages?
 * We don't plan on becoming a full blown code repository, or do we? Worth 
worrying about?
 * Should we suggest (not enforce) coding standards?

And lastly, one problem about coding examples is how good practice can dilute 
the example. So for example, while teaching people about $_GET['foo'] we may 
end up with one of:
 A) echo htmlspecialchars($_GET['foo'], ENT_QUOTES, 'UTF-8'); // Hello World
 B) echo $_GET['foo']; // Hello World

The (A) dilutes the idea of $_GET whereas (B) is clear. So which is the better 
example? Probably (A) in this case but the point is it's not straightforward.

All thoughts welcome. Or, KISS? :)

Regards,
Philip

Reply via email to