(file) Return to CodingGuidelines.htm CVS log (file) (dir) Up to [Pegasus] / pegasus / doc

Diff for /pegasus/doc/CodingGuidelines.htm between version 1.4 and 1.5

version 1.4, 2013/05/03 05:34:37 version 1.5, 2013/12/02 12:13:46
Line 1 
Line 1 
 <html>  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
   <html><head>
   
  
 <head>  
 <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Language" content="en-us">
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>PEP 221 - Pegasus Coding Conventions</title>
 <title>PEP 221 - Pegasus Coding Conventions</title>  
 <link rel="stylesheet" href="http://www.opengroup.org/stylesheets/info1+margins.css">  
 </head>  
  
 <body>  <link rel="stylesheet" href="http://www.opengroup.org/stylesheets/info1+margins.css"></head><body>
  
 <hr> <hr>
  
Line 16 
Line 14 
 <p><b>Title:</b> Pegasus Coding Conventions</p> <p><b>Title:</b> Pegasus Coding Conventions</p>
 <p><b>Status:</b> Approved</p> <p><b>Status:</b> Approved</p>
 <p><b>Version History:</b></p> <p><b>Version History:</b></p>
 <table border="1" cellspacing="1" bordercolordark="#666666"  <table bordercolordark="#666666" bordercolorlight="#CCCCCC" style="font-family: Arial;" border="1" cellspacing="1" width="100%">
     bordercolorlight="#CCCCCC" width=100%    <tbody><tr>
     style='font-size=10.0pt;font-family:Arial'>      <th bgcolor="#cae6ca">Version</th>
   <tr>      <th bgcolor="#cae6ca">Date</th>
     <th bgcolor="#CAE6CA">Version</th>      <th bgcolor="#cae6ca">Author</th>
     <th bgcolor="#CAE6CA">Date</th>      <th bgcolor="#cae6ca">Change Description</th>
     <th bgcolor="#CAE6CA">Author</th>  
     <th bgcolor="#CAE6CA">Change Description</th>  
   </tr>   </tr>
   <tr>   <tr>
     <td align="center">1.0</td>     <td align="center">1.0</td>
Line 110 
Line 106 
     <td align="center">22 January 2013</td>     <td align="center">22 January 2013</td>
     <td align="center">Marek Szermutzky</td>     <td align="center">Marek Szermutzky</td>
     <td>macro PEGASUS_FCT_EXECUTE_AND_ASSERT added</td>     <td>macro PEGASUS_FCT_EXECUTE_AND_ASSERT added</td>
     </tr><tr>
         <td style="vertical-align: top; text-align: center;">3.6<br>
         </td>
         <td style="vertical-align: top; text-align: center;">19 November 2013<br>
         </td>
         <td style="vertical-align: top;">Karl Schopmeyer<br>
         </td>
         <td style="vertical-align: top;">Add rule about defaults in switch constructs (see Formatting, 22)<br>
         </td>
   </tr>   </tr>
 </table>  
   </tbody></table>
 <p>&nbsp;</p> <p>&nbsp;</p>
 <hr> <hr>
 <p><b>Abstract:</b> This document formalizes the Pegasus coding conventions. <p><b>Abstract:</b> This document formalizes the Pegasus coding conventions.
Line 119 
Line 125 
 <hr> <hr>
  
 <h2><font color="#000000">Definition of the Problem</font></h2> <h2><font color="#000000">Definition of the Problem</font></h2>
 <p><The use of inconsistent coding styles is an impediment to  <p><the use="" inconsistent="" styles="" is="" an="" impediment="" effective="" development="" and="" maintenance="" code.="" formalization="" of="" pegasus="" coding="" conventions="" may="" help="" to="" improve="" code="" consistency.=""></the></p>
 effective development and maintenance of Pegasus code.  Formalization of  
 Pegasus coding conventions may help to improve code consistency.  
 </p>  
  
 <h2><font color="#000000">Proposed Solution</font></h2> <h2><font color="#000000">Proposed Solution</font></h2>
 <p>The following items comprise the Pegasus coding conventions.</p> <p>The following items comprise the Pegasus coding conventions.</p>
  
 <h3>Formatting</h3> <h3>Formatting</h3>
 <ol> <ol>
   
   <li>Indent by increments of four spaces.  Indent comments   <li>Indent by increments of four spaces.  Indent comments
       equally with the associated code.</li>       equally with the associated code.</li>
   <li>Do not use tab characters.</li>   <li>Do not use tab characters.</li>
Line 139 
Line 143 
   <li>Put opening brace on a line by itself, aligned with control keyword   <li>Put opening brace on a line by itself, aligned with control keyword
       or method signature.       or method signature.
       Do this:       Do this:
       <pre><code>    for (...)        <pre><code>    for (...)<br>    {<br>    }</code></pre>
     {  
     }</code></pre>  
       Not this:       Not this:
       <pre><code>    for (...) {        <pre><code>    for (...) {<br>    }</code></pre>
     }</code></pre>  
       Or this:       Or this:
       <pre><code>    for (...)        <pre><code>    for (...)<br>      {<br>      }</code></pre>
       {  
       }</code></pre>  
   </li>   </li>
   <li>Use braces around the body of a control block (e.g., <code>if</code>,   <li>Use braces around the body of a control block (e.g., <code>if</code>,
       <code>for</code>, or <code>while</code> statement), even if the body       <code>for</code>, or <code>while</code> statement), even if the body
       contains just a single statement.       contains just a single statement.
       Do this:       Do this:
       <pre><code>    for (...)        <pre><code>    for (...)<br>    {<br>        i++;<br>    }</code></pre>
     {  
         i++;  
     }</code></pre>  
       Not this:       Not this:
       <pre><code>    for (...)        <pre><code>    for (...)<br>        i++;</code></pre>
         i++;</code></pre>  
   </li>   </li>
   <li>Use a new line for <code>else</code> statements rather   <li>Use a new line for <code>else</code> statements rather
       than placing then on the same line as a preceding '<code>}</code>'.       than placing then on the same line as a preceding '<code>}</code>'.
       Do this:       Do this:
       <pre><code>    if (...)        <pre><code>    if (...)<br>    {<br>        i++;<br>    }<br>    else<br>    {<br>        j++;<br>    }</code></pre>
     {        Not this:
         i++;        <pre><code>    if (...)<br>    {<br>        i++;<br>    } else<br>    {<br>        j++;<br>    }</code></pre>
     }  
     else  
     {  
         j++;  
     }</code></pre>  
       Not this:  
       <pre><code>    if (...)  
     {  
         i++;  
     } else  
     {  
         j++;  
     }</code></pre>  
   </li>   </li>
   <li>Use normal indenting for parameters in a complex method signature:   <li>Use normal indenting for parameters in a complex method signature:
       <pre><code>    void MyClass::myMethod(        <pre><code>    void MyClass::myMethod(<br>        const char* someReallyLongName,<br>        const char* someOtherReallyLongName);</code></pre>
         const char* someReallyLongName,  
         const char* someOtherReallyLongName);</code></pre>  
   </li>   </li>
   <li>Use normal indenting for all arguments in a complex function call.   <li>Use normal indenting for all arguments in a complex function call.
       Do this:       Do this:
       <pre><code>    callingMyFunction(        <pre><code>    callingMyFunction(<br>        arg1,<br>        arg2,<br>        arg3);</code></pre>
         arg1,        Not this:
         arg2,        <pre><code>    callingMyFunction(arg1,<br>                      arg2,<br>                      arg3);</code></pre>
         arg3);</code></pre>  
       Not this:  
       <pre><code>    callingMyFunction(arg1,  
                       arg2,  
                       arg3);</code></pre>  
       Each argument should be placed on a separate line.       Each argument should be placed on a separate line.
       An exception is made for <code>PEG_TRACE</code> and       An exception is made for <code>PEG_TRACE</code> and
       <code>PEG_TRACE_CSTRING</code> statements, where the first two       <code>PEG_TRACE_CSTRING</code> statements, where the first two
       arguments should be placed on the opening line:       arguments should be placed on the opening line:
       <pre><code>    PEG_TRACE((TRC_HTTP, Tracer::LEVEL3,        <pre><code>    PEG_TRACE((TRC_HTTP, Tracer::LEVEL3,<br>        "Connection IP address = %s",<br>        (const char*)_ipAddress.getCString()));</code></pre>
         "Connection IP address = %s",  
         (const char*)_ipAddress.getCString()));</code></pre>  
   </li>   </li>
   <li>For an <code>if</code>, <code>while</code>, or <code>for</code>   <li>For an <code>if</code>, <code>while</code>, or <code>for</code>
       condition that does not fit on a single line, indent peer subconditions       condition that does not fit on a single line, indent peer subconditions
       according to their level of nesting and indent other continuation lines       according to their level of nesting and indent other continuation lines
       using normal indenting.  Do this:       using normal indenting.  Do this:
       <pre><code>    if ((variable1 == variable2) ||        <pre><code>    if ((variable1 == variable2) ||<br>        ((anotherVariableToConsider ==<br>              variable1 + variable2) &amp;&amp;<br>         (dayOfWeek == "Tuesday")))</code></pre>
         ((anotherVariableToConsider ==        Not this:
               variable1 + variable2) &&        <pre><code>    if ((variable1 == variable2) ||<br>            ((anotherVariableToConsider ==<br>              variable1 + variable2) &amp;&amp;<br>                 (dayOfWeek == "Tuesday")))</code></pre>
          (dayOfWeek == "Tuesday")))</code></pre>  
       Not this:  
       <pre><code>    if ((variable1 == variable2) ||  
             ((anotherVariableToConsider ==  
               variable1 + variable2) &&  
                  (dayOfWeek == "Tuesday")))</code></pre>  
   </li>   </li>
   <li>For a statement that does not fit on a single line,   <li>For a statement that does not fit on a single line,
       all continuation lines should be indented once from the first line.       all continuation lines should be indented once from the first line.
       For example:       For example:
       <pre><code>    sum = a + b + c +        <pre><code>    sum = a + b + c +<br>        d + e + f +<br>        g + h;</code></pre>
         d + e + f +  
         g + h;</code></pre>  
   </li>   </li>
   <li>Do not separate a return type onto its own line.  Avoid this:   <li>Do not separate a return type onto its own line.  Avoid this:
       <pre><code>    int        <pre><code>    int<br>    f()<br>    {<br>    }</code></pre>
     f()  
     {  
     }</code></pre>  
   </li>   </li>
   <li>Avoid use of &quot;<code>(void)</code>&quot; for an empty parameter list.    <li>Avoid use of "<code>(void)</code>" for an empty parameter list.
       Use &quot;<code>()</code>&quot; instead.        Use "<code>()</code>" instead.
   </li>   </li>
   <li>Avoid adding a space between function/method name the opening parenthesis.   <li>Avoid adding a space between function/method name the opening parenthesis.
       Do this:       Do this:
       <pre><code>    void f(int i);        <pre><code>    void f(int i);<br>    f(10);</code></pre>
     f(10);</code></pre>  
       Not this:       Not this:
       <pre><code>    void f (int i);        <pre><code>    void f (int i);<br>    f (10);</code></pre>
     f (10);</code></pre>  
   </li>   </li>
   <li>Include a space between a keyword and an opening parenthesis.   <li>Include a space between a keyword and an opening parenthesis.
       Do this:       Do this:
       <pre><code>    if (i > 0)        <pre><code>    if (i &gt; 0)<br>    for (i = 0; i &lt; 10; i++)</code></pre>
     for (i = 0; i < 10; i++)</code></pre>  
       Not this:       Not this:
       <pre><code>    if(i > 0)        <pre><code>    if(i &gt; 0)<br>    for(i = 0; i &lt; 10; i++)</code></pre>
     for(i = 0; i < 10; i++)</code></pre>  
   </li>   </li>
   <li>Do not add spaces around a condition.  Do this:   <li>Do not add spaces around a condition.  Do this:
       <pre><code>    if (cond)        <pre><code>    if (cond)<br>    while (cond)</code></pre>
     while (cond)</code></pre>  
       Not this:       Not this:
       <pre><code>    if ( cond )        <pre><code>    if ( cond )<br>    while ( cond )</code></pre>
     while ( cond )</code></pre>  
   </li>   </li>
   <li>Do not add a space between a template name and its type.  Do this:   <li>Do not add a space between a template name and its type.  Do this:
       <pre><code>    Array&lt;Uint8&gt; myArray;</code></pre>       <pre><code>    Array&lt;Uint8&gt; myArray;</code></pre>
Line 264 
Line 220 
       <pre><code>    Array &lt;Uint8&gt; myArray;</code></pre>       <pre><code>    Array &lt;Uint8&gt; myArray;</code></pre>
   </li>   </li>
   <li>Avoid aligning variable names in a declaration list.  Do this:   <li>Avoid aligning variable names in a declaration list.  Do this:
       <pre><code>    int x;        <pre><code>    int x;<br>    float y;</code></pre>
     float y;</code></pre>  
       Not this:       Not this:
       <pre><code>    int      x;        <pre><code>    int      x;<br>    float    y;</code></pre>
     float    y;</code></pre>  
   </li>   </li>
   <li>Avoid indenting &quot;<code>public:</code>&quot;,    <li>Avoid indenting "<code>public:</code>",
       &quot;<code>protected:</code>&quot;, and        "<code>protected:</code>", and
       &quot;<code>private:</code>&quot;. Do this:        "<code>private:</code>". Do this:
       <pre><code>    class X        <pre><code>    class X<br>    {<br>    public:<br>        int f();<br>        ...<br>    private:<br>        int _g();<br>        ...<br>    };</code></pre>
     {  
     public:  
         int f();  
         ...  
     private:  
         int _g();  
         ...  
     };</code></pre>  
   </li>   </li>
   <li>The '<code>#</code>' indicating a preprocessing directive is placed   <li>The '<code>#</code>' indicating a preprocessing directive is placed
       at the beginning of a line.  Nested preprocessing directives are       at the beginning of a line.  Nested preprocessing directives are
       indented with one space after the '<code>#</code>' for each level of       indented with one space after the '<code>#</code>' for each level of
       nesting.  The <code>#ifndef</code> used for header file include protection       nesting.  The <code>#ifndef</code> used for header file include protection
       is not considered a level of nesting.  For example:       is not considered a level of nesting.  For example:
       <pre><code>#ifdef PEGASUS_HAS_SIGNALS        <pre><code>#ifdef PEGASUS_HAS_SIGNALS<br># ifdef PEGASUS_OS_TYPE_WINDOWS<br>#  include &lt;windows.h&gt;<br># else<br>#  include &lt;unistd.h&gt;<br># endif<br>#endif</code></pre>
 # ifdef PEGASUS_OS_TYPE_WINDOWS  
 #  include &lt;windows.h&gt;  
 # else  
 #  include &lt;unistd.h&gt;  
 # endif  
 #endif</code></pre>  
   </li>   </li>
   <li>In a <code>switch</code> statement, indent the <code>case</code>   <li>In a <code>switch</code> statement, indent the <code>case</code>
       statement from the <code>switch</code> and indent the case logic from       statement from the <code>switch</code> and indent the case logic from
       the <code>case</code> statement.  For example:       the <code>case</code> statement.  For example:
       <pre><code>    switch(n)        <pre><code>    switch(n)<br>    {<br>        case 0:<br>            printf("Rock");<br>            break;<br>        case 1:<br>            printf("Paper");<br>            break;<br>        case 2:<br>            printf("Scissors");<br>            break;<br>        default:<br>            printf("Error");<br>            break;<br>    }</code></pre></li>
     {    <li>A <code>switch </code>construct for an enumerated type the
         case 0:  construct MUST contain either all of the possible cases&nbsp; or the
             printf("Rock");  default statement but not both. We encourage including all of the
             break;  enumerated types since this provides a compile time check if the
         case 1:  enumerated type changes.&nbsp; Do not include the default statement if
             printf("Paper");  all of the possible enumerated types are included in the <code>case</code>
             break;  statements. At least in gcc this is enforced in the standard build with
         case 2:  the -Werror=switch flag which generates an error statement when the <code>switch</code> has an index of enumerated type
             printf("Scissors");  and lacks a <code>case</code> for one or more of the named codes of that
             break;  enumeration.</li>
         default:  
             printf("Error");  
             break;  
     }</code></pre>  
   </li>  
   <li>Do not put parentheses around the return value in a   <li>Do not put parentheses around the return value in a
       <code>return</code> statement.       <code>return</code> statement.
   </li>   </li>
 </ol> </ol>
  
   
 <h3>Naming</h3> <h3>Naming</h3>
 <ol> <ol>
   
   <li>For class/struct names, use mixed case with initial upper case and   <li>For class/struct names, use mixed case with initial upper case and
       no underscores: <code>ThisIsAClassName</code>.       no underscores: <code>ThisIsAClassName</code>.
   </li>   </li>
Line 348 
Line 286 
   <li>Environment variables must begin with <code>PEGASUS_</code> and have   <li>Environment variables must begin with <code>PEGASUS_</code> and have
       this form: <code>PEGASUS_ENVIRONMENT_VARIABLE</code>.       this form: <code>PEGASUS_ENVIRONMENT_VARIABLE</code>.
       This applies to environment variables that control the build and test       This applies to environment variables that control the build and test
       configuration as well as those (if any) used by Pegasus at run time.        configuration as well as those (if any) used by Pegasus at run time by forcing an error if the&nbsp;
   </li>   </li>
   <li>Test executable names should begin with 'Test' (to distinguish them   <li>Test executable names should begin with 'Test' (to distinguish them
       from other executables) and should use mixed case with initial upper       from other executables) and should use mixed case with initial upper
Line 357 
Line 295 
   </li>   </li>
 </ol> </ol>
  
   
 <h3>Style</h3> <h3>Style</h3>
 <ol> <ol>
   <li>In a header file, use angle brackets (with a fully qualified path)   <li>In a header file, use angle brackets (with a fully qualified path)
       rather than quotes when including a file.  Do this:       rather than quotes when including a file.  Do this:
       <pre><code>    #include &lt;Pegasus/Common/Array.h&gt;</code></pre>       <pre><code>    #include &lt;Pegasus/Common/Array.h&gt;</code></pre>
       Not this:       Not this:
       <pre><code>    #include &quot;Array.h&quot;</code></pre>        <pre><code>    #include "Array.h"</code></pre>
   </li>   </li>
   <li>Use &quot;<code>0</code>&quot; rather than &quot;<code>NULL</code>&quot;    <li>Use "<code>0</code>" rather than "<code>NULL</code>"
       as a null pointer value.       as a null pointer value.
   </li>   </li>
   <li>Avoid <code>throw()</code> declarations.  These may be used   <li>Avoid <code>throw()</code> declarations.  These may be used
Line 385 
Line 324 
       String construction:       String construction:
       <pre><code>    String s = foo();</code></pre>       <pre><code>    String s = foo();</code></pre>
       while this logic causes two String constructions and an assignment:       while this logic causes two String constructions and an assignment:
       <pre><code>    String s;        <pre><code>    String s;<br>    ...<br>    s = foo();</code></pre>
     ...  
     s = foo();</code></pre>  
       </li>       </li>
   <li>Present resources as part of classes, do not use them directly.</li>   <li>Present resources as part of classes, do not use them directly.</li>
   <li>Use <code>new</code> and <code>delete</code> to manage dynamic   <li>Use <code>new</code> and <code>delete</code> to manage dynamic
Line 397 
Line 334 
       block, avoid specifying the object to throw so that exception subtype       block, avoid specifying the object to throw so that exception subtype
       information is not lost and construction of an extra exception       information is not lost and construction of an extra exception
       object is avoided.  Do this:       object is avoided.  Do this:
       <pre><code>    catch (Exception&)        <pre><code>    catch (Exception&amp;)<br>    {<br>        ...<br>        throw;<br>    }</code></pre>
     {        Not this:
         ...        <pre><code>    catch (Exception&amp; e)<br>    {<br>        ...<br>        throw e;<br>    }</code></pre></li>
         throw;  
     }</code></pre>  
       Not this:  
       <pre><code>    catch (Exception& e)  
     {  
         ...  
         throw e;  
     }</code></pre></li>  
   <li>Do not check whether a pointer is non-null before   <li>Do not check whether a pointer is non-null before
       deleting it.  The check is unnecessary, since it is also performed by       deleting it.  The check is unnecessary, since it is also performed by
       the <code>delete</code> operator.  Do this:       the <code>delete</code> operator.  Do this:
       <pre><code>    delete ptr;</code></pre>       <pre><code>    delete ptr;</code></pre>
       Not this:       Not this:
       <pre><code>    if (ptr)        <pre><code>    if (ptr)<br>    {<br>        delete ptr;<br>    }</code></pre></li>
     {  
         delete ptr;  
     }</code></pre></li>  
   <li>Avoid using the compiler default implementations for   <li>Avoid using the compiler default implementations for
       default constructors, copy constructors, and assignment operators.       default constructors, copy constructors, and assignment operators.
       These should be declared as private and left unimplemented if they       These should be declared as private and left unimplemented if they
Line 432 
Line 358 
       </li>       </li>
   <li>Pass object parameters by reference, when feasible,   <li>Pass object parameters by reference, when feasible,
       to avoid unnecessary copy constructions.  For example, this:       to avoid unnecessary copy constructions.  For example, this:
       <pre><code>    void func(const String& s);</code></pre>        <pre><code>    void func(const String&amp; s);</code></pre>
       is preferred to this:       is preferred to this:
       <pre><code>    void func(String s);</code></pre></li>       <pre><code>    void func(String s);</code></pre></li>
   <li>Avoid using the C++ standard template library (STL) and the standard   <li>Avoid using the C++ standard template library (STL) and the standard
Line 464 
Line 390 
       comments.       comments.
   </li>   </li>
   <li>Use this comment style for DOC++ comments:   <li>Use this comment style for DOC++ comments:
       <pre><code>    class X        <pre><code>    class X<br>    {<br>    public:<br><br>        /**<br>            Creates widgets.<br>            @param numWidgets The number of widgets to create.<br>            @return true if successful, false otherwise.<br>        */<br>        Boolean createWidgets(Uint32 numWidgets);<br>    };</code></pre>
     {  
     public:  
   
         /**  
             Creates widgets.  
             @param numWidgets The number of widgets to create.  
             @return true if successful, false otherwise.  
         */  
         Boolean createWidgets(Uint32 numWidgets);  
     };</code></pre>  
   </li>   </li>
   <li>A description should end with a period, even if it is brief:   <li>A description should end with a period, even if it is brief:
       <pre><code>    /**        <pre><code>    /**<br>        Does something useful.<br>    */</code></pre>
         Does something useful.  
     */</code></pre>  
   </li>   </li>
   <li>Add a blank line between documented methods:   <li>Add a blank line between documented methods:
       <pre><code>    /**        <pre><code>    /**<br>        Does something quite useful.<br>    */<br>    void f();<br><br>    /**<br>        The previous method has a newline after it<br>        to improve its visibility.<br>    */<br>    void g();</code></pre>
         Does something quite useful.  
     */  
     void f();  
   
     /**  
         The previous method has a newline after it  
         to improve its visibility.  
     */  
     void g();</code></pre>  
   </li>   </li>
 </ol> </ol>
  
Line 525 
Line 430 
       define a <code>PEGASUS_&lt;LIBRARY&gt;_LINKAGE</code> symbol in a       define a <code>PEGASUS_&lt;LIBRARY&gt;_LINKAGE</code> symbol in a
       Linkage.h file.  Each symbol that is exported from the library       Linkage.h file.  Each symbol that is exported from the library
       must be declared with this linkage macro.  For example:       must be declared with this linkage macro.  For example:
       <pre><code>    class PEGASUS_COMMON_LINKAGE String;        <pre><code>    class PEGASUS_COMMON_LINKAGE String;<br><br>    PEGASUS_COMMON_LINKAGE void globalFunction();</code></pre>
   
     PEGASUS_COMMON_LINKAGE void globalFunction();</code></pre>  
   </li>   </li>
   <li>A <code>main()</code> function must return an int (required by   <li>A <code>main()</code> function must return an int (required by
       Windows NT).       Windows NT).
Line 539 
Line 442 
       <pre><code>    void f() throw TooBad;</code></pre>       <pre><code>    void f() throw TooBad;</code></pre>
   </li>   </li>
   <li>Do not include a definition of a static member with its declaration:   <li>Do not include a definition of a static member with its declaration:
       <pre><code>    class X        <pre><code>    class X<br>    {<br>    public:<br><br>        static const Uint32 COLOR = 225;<br>    };</code></pre>
     {  
     public:  
   
         static const Uint32 COLOR = 225;  
     };</code></pre>  
       Use this instead:       Use this instead:
       <pre><code>    class X        <pre><code>    class X<br>    {<br>    public:<br><br>        static const Uint32 COLOR;<br>    };</code></pre>
     {  
     public:  
   
         static const Uint32 COLOR;  
     };</code></pre>  
       And add the definition in the source file:       And add the definition in the source file:
       <pre><code>    const Uint32 X::COLOR = 225;</code></pre>       <pre><code>    const Uint32 X::COLOR = 225;</code></pre>
   </li>   </li>
Line 559 
Line 452 
       printf and scanf conversions of 64-bit integers rather than       printf and scanf conversions of 64-bit integers rather than
       <code>ll</code> or <code>L</code>.       <code>ll</code> or <code>L</code>.
       Do this:       Do this:
       <pre><code>    Sint64 i64 = 10;        <pre><code>    Sint64 i64 = 10;<br>    printf("i64 value = %" PEGASUS_64BIT_CONVERSION_WIDTH "d.\n", i64);</code></pre>
     printf(&quot;i64 value = %&quot; PEGASUS_64BIT_CONVERSION_WIDTH &quot;d.\n&quot;, i64);</code></pre>  
       Instead of this:       Instead of this:
       <pre><code>    Sint64 i64 = 10;        <pre><code>    Sint64 i64 = 10;<br>    printf("i64 value = %lld.\n", i64);</code></pre>
     printf(&quot;i64 value = %lld.\n&quot;, i64);</code></pre>  
   </li>   </li>
   <li>Do not include class scoping on methods or members in a class definition.   <li>Do not include class scoping on methods or members in a class definition.
       Do this:       Do this:
       <pre><code>    class X        <pre><code>    class X<br>    {<br>    public:<br><br>        int myMethod();<br>    };</code></pre>
     {        Not this:
     public:        <pre><code>    class X<br>    {<br>    public:<br><br>        int X::myMethod();<br>    };</code></pre>
   
         int myMethod();  
     };</code></pre>  
       Not this:  
       <pre><code>    class X  
     {  
     public:  
   
         int X::myMethod();  
     };</code></pre>  
   </li>   </li>
   <li>Do not use <code>Pegasus::</code> to scope symbols.  Not all platforms   <li>Do not use <code>Pegasus::</code> to scope symbols.  Not all platforms
       support C++ namespaces, and this will cause a compilation failure.  If       support C++ namespaces, and this will cause a compilation failure.  If
Line 604 
Line 485 
     definition while keeping the parameter type in place. In the     definition while keeping the parameter type in place. In the
     following example of function <i>main()</i> the parameter <i>argv</i>     following example of function <i>main()</i> the parameter <i>argv</i>
     is used later on but parameter <i>argc</i> is not. Do this:<br>     is used later on but parameter <i>argc</i> is not. Do this:<br>
     <pre><code>int main(int, void** argv)      <pre><code>int main(int, void** argv)<br>{<br>}</code></pre>
 {  
 }</code></pre>  
     Not this:<br>     Not this:<br>
     <pre><code>int main(int argc, void** argv)      <pre><code>int main(int argc, void** argv)<br>{<br>}</code></pre>
 {  
 }</code></pre>  
   </li>   </li>
   <li>Avoid unused variables when the return value of a function is   <li>Avoid unused variables when the return value of a function is
     assigned to a variable only to be used to do an assert check     assigned to a variable only to be used to do an assert check
Line 621 
Line 498 
     value of function against VALUE for equalness but only if     value of function against VALUE for equalness but only if
     asserts are enabled. The Function FCT will always be called     asserts are enabled. The Function FCT will always be called
     (equal if asserts enabled or disabled). Do this:     (equal if asserts enabled or disabled). Do this:
     <pre><code>PEGASUS_FCT_EXECUTE_AND_ASSERT(true, f());      <pre><code>PEGASUS_FCT_EXECUTE_AND_ASSERT(true, f());<br>    </code></pre>
     </code></pre>  
     Not this:     Not this:
     <pre><code>bool returnCode = f();<br>PEGASUS_ASSERT(true == returnCode);      <pre><code>bool returnCode = f();<br>PEGASUS_ASSERT(true == returnCode);<br>    </code></pre>
     </code></pre>  
   </li>   </li>
  
 </ol> </ol>
Line 633 
Line 508 
  
 <h2><font color="#000000">Discussion</font></h2> <h2><font color="#000000">Discussion</font></h2>
 <p>Suggestions for additional conventions are listed here for discussion: <p>Suggestions for additional conventions are listed here for discussion:
 <ul>  </p><ul>
   <li>Handling of error conditions (cerr vs. logging) and exceptions</li>   <li>Handling of error conditions (cerr vs. logging) and exceptions</li>
   <li>Testing (perhaps reference another document)</li>   <li>Testing (perhaps reference another document)</li>
   <li>Is it appropriate to make a statement about defining   <li>Is it appropriate to make a statement about defining
       localizable messages in the appropriate message bundle?       localizable messages in the appropriate message bundle?
   </li>   </li>
 </ul> </ul>
 </p>  <p></p>
  
  
 <hr> <hr>
Line 650 
Line 525 
 <br> <br>
 <font size="1">Permission is hereby granted, free of charge, to any person <font size="1">Permission is hereby granted, free of charge, to any person
 obtaining a copy&nbsp; of this software and associated documentation files obtaining a copy&nbsp; of this software and associated documentation files
 (the &quot;Software&quot;), to deal in the Software without restriction,  (the "Software"), to deal in the Software without restriction,
 including without limitation the rights to use, copy, modify, merge, publish, including without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to permit distribute, sublicense, and/or sell copies of the Software, and to permit
 persons to whom the Software is furnished to do so, subject to the following persons to whom the Software is furnished to do so, subject to the following
Line 659 
Line 534 
 </font> </font>
 <font size="1">THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE <font size="1">THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE
 INCLUDED IN ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS INCLUDED IN ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS
 PROVIDED&nbsp; &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  PROVIDED&nbsp; "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Line 670 
Line 545 
 <p>Template last modified: <b>March 9th 2004</b> by <b>Martin Kirk<br> <p>Template last modified: <b>March 9th 2004</b> by <b>Martin Kirk<br>
 </b>Template version: <b>1.8</b></p> </b>Template version: <b>1.8</b></p>
  
 </body>  </body></html>
   
 </html>  


Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2