Title: [90027] trunk/Websites/webkit.org
Revision
90027
Author
[email protected]
Date
2011-06-29 10:57:00 -0700 (Wed, 29 Jun 2011)

Log Message

2011-06-29  Leandro Pereira  <[email protected]>

        Reviewed by Darin Adler.

        Add note about cases where enums are preferred over bools on function parameters.
        https://bugs.webkit.org/show_bug.cgi?id=63564

        This matches the outcome of this webkit-dev thread:
        https://lists.webkit.org/pipermail/webkit-dev/2010-December/015192.html

        * coding/coding-style.html:

Modified Paths

Diff

Modified: trunk/Websites/webkit.org/ChangeLog (90026 => 90027)


--- trunk/Websites/webkit.org/ChangeLog	2011-06-29 17:46:56 UTC (rev 90026)
+++ trunk/Websites/webkit.org/ChangeLog	2011-06-29 17:57:00 UTC (rev 90027)
@@ -1,3 +1,15 @@
+2011-06-29  Leandro Pereira  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Add note about cases where enums are preferred over bools on function parameters.
+        https://bugs.webkit.org/show_bug.cgi?id=63564
+
+        This matches the outcome of this webkit-dev thread:
+        https://lists.webkit.org/pipermail/webkit-dev/2010-December/015192.html
+
+        * coding/coding-style.html:
+
 2011-05-31  Chris Evans  <[email protected]>
 
         Reviewed by Drew Yao.

Modified: trunk/Websites/webkit.org/coding/coding-style.html (90026 => 90027)


--- trunk/Websites/webkit.org/coding/coding-style.html	2011-06-29 17:46:56 UTC (rev 90026)
+++ trunk/Websites/webkit.org/coding/coding-style.html	2011-06-29 17:57:00 UTC (rev 90027)
@@ -603,6 +603,24 @@
 </pre>
 </li>
 
+<li>Prefer enums to bools on function parameters if callers are likely to be
+passing constants, since named constants are easier to read at the call
+site.  An exception to this rule is a setter function, where the name of the
+function already makes clear what the boolean is.
+<h4 class="right">Right:</h4>
+<pre class="code">
+doSomething(something, AllowFooBar);
+paintTextWithShadows(context, ..., textStrokeWidth > 0, isHorizontal());
+setResizable(false);
+</pre>
+
+<h4 class="wrong">Wrong:</h4>
+<pre class="code">
+doSomething(something, false);
+setResizable(NotResizable);
+</pre>
+</li>
+
 <li>Objective-C method names should follow the Cocoa naming guidelines &mdash;
 they should read like a phrase and each piece of the selector should 
 start with a lowercase letter and use intercaps.</li>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to