On Mon, Jul 28, 2008 at 1:39 PM, Hans-Christoph Steiner hans@eds.org wrote:
I think a style guide is a great idea. There have been some discussions along these lines in the past. I'd say just start a "wiki folder" on puredata.info in the /docs/ section and edit it up. Something like /docs/style-guide/ I think that the main page could lay out all of the possible realms of style, like dollar arguments, abstractions, subpatches, inlets/outlets, trigger, etc. Then the next step people can create sub-pages that outline all of their styles. Then ultimately, things would be organized into a single style-guide.
Okay, here it is: http://puredata.info/docs/style-guide
.hc
On Jul 27, 2008, at 9:34 PM, Luke Iannini wrote:
There are some amazing sets of abstractions being released recently, which has served to highlight the many extant styles of patching. I was wondering if there was interest in establishing a set of guidelines for patching in the vein of PEP 8 for Python; I've found that document to be very relaxing as it is a standardized approach to OCD. More seriously, it greatly helps when reading other people's code or collaborating. http://www.python.org/dev/peps/pep-0008/
The only one I have seen so far for Pd covers best practices for layout. I'd want to include that, but also codify naming, arguments, common idioms, and so on.
I've begun to collect some of my practices to start things off. I was hoping we could all lazy-vote the document together in this thread and I'll then compile it into a PdPedia/Pd.info document. So, feel free to object to or replace my propositions.
Style:
- If giving $0 as an argument to an abstraction, it is always first in
the argument list [1]
- When possible, pass parent arguments in numeric order, like [child
$0 $1 $2 other1 other2] etc.
- Sends and Receives are written in camelCase, with "R" appended to
complementary receives (e.g. in GUIs, $0mySlider for the send and $0mySliderR for the receive)
- When prepending $0 to a symbol, only add a "-" to separate it from
another number, like [r $0-1stSend]. Otherwise the symbol should immediately follow, like [r $0mySend].
- When working with stereo, Left and Right pairs are written with Le
and Ri appended (to distinguish them from an R denoting "receive", above)
Programming recommendations
- To invert a toggle, use [== 0]
- Use the loadbang of the parent of both abstractions to initialize
two or more interdependent abstractions
[1] I think of this like emulating the "self" convention in Python
And so on... Cheers Luke
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Terrorism is not an enemy. It cannot be defeated. It's a tactic. It's about as sensible to say we declare war on night attacks and expect we're going to win that war. We're not going to win the war on terrorism. - retired U.S. Army general, William Odom
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list