[Pidgin] StyleGuide modified

Pidgin trac at pidgin.im
Fri Feb 28 02:31:36 EST 2014


Page "StyleGuide" was changed by MarkDoliner
Diff URL: <https://developer.pidgin.im/wiki/StyleGuide?action=diff&version=11>
Revision 11
Changes:
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: StyleGuide
=========================================================================
--- StyleGuide (version: 10)
+++ StyleGuide (version: 11)
@@ -85,6 +85,26 @@
 }}}
 
 
-== Variable Declarations ==
+== Variables ==
  * Prefer declaring each variable on its own line. This makes diffs easier to read and reduces churn. It also makes the code more clear when one variable is given an initial value but another is not.
  * Use const for variables that don't need to change or be deallocated.
+ * Avoid assigning variables in conditions unless it leads to simpler logic, e.g.:
+{{{
+#!c
+/* Don't do this: */
+if ((written = write(fd, buf, len)) < len) {
+        ...
+}
+
+/* Do this -- it's easier to read and leads to
+ * cleaner diffs when things change: */
+written = write(fd, buf, len);
+if (written < len) {
+        ...
+}
+
+/* But this if often ok, because the alternative might be unwieldy: */
+while (has_next = get_next()) {
+        ...
+}
+}}}
-------8<------8<------8<------8<------8<------8<------8<------8<--------

--
Page URL: <https://developer.pidgin.im/wiki/StyleGuide>
Pidgin <https://pidgin.im>
Pidgin

This is an automated message. Someone added your email address to be
notified of changes on 'StyleGuide' page.
If it was not you, please report to datallah at pidgin.im.


More information about the Wikiedit mailing list